package com.hsnn.medstgmini.pro.base.dao.Impl;

import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hsnn.medstgmini.dao.HibernateSqlUtil;
import com.hsnn.medstgmini.pro.base.dao.AnaDruginfoDao;
import com.hsnn.medstgmini.util.AreaUtil;
import com.hsnn.medstgmini.util.DateUtil;
import com.hsnn.medstgmini.util.Pagination;
import com.hsnn.medstgmini.util.ParseDate;

@Service
public class AnaDruginfoDaoImpl implements AnaDruginfoDao {
	@Autowired
	private HibernateSqlUtil dao;
	
	/**
	 * 
	 *@category 按药品汇总统计（每日）
	 *@author lil
	 *@date 2015年12月4日 
	 *@param 
	 *@return Pagination
	 */
	@Override
	public Pagination getAnaByDrugs(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ad.*,bgi.qualityspec_name drug_name,bgi.form_name,bgi.spec_name, ")
		.append(" bgi.factor,bgi.unit_name,bgi.material_name,bgi.prod_compname,bgi.prod_compcode ")
		.append(" from ana_druginfo ad left join base_goods_item bgi on bgi.drug_code =ad.drug_code where 1=1  ");
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("isBasic"))){
			sql.append(" and ad.is_basic=:isBasic ");
		}
		sql.append(" ORDER BY ad.date desc ");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}

	@Override
	public Pagination getAnaByHosp(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.hosp_code,ah.hosp_name,ah.date, ")
		.append(" ah.hosp_classify,ah.total_amount,ah.base_amount,ah.nonbase_amount,ah.ret_amount, ")
		.append(" ah.base_ratio, ")
		.append(" ah.ret_ratio ")
		.append("  from ana_hospital ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("hospName"))) {
			sql.append(" and (ah.hosp_name like :hospName or ah.hosp_spel_code like :hospName )");
			map.put("hospName", "%"+map.get("hospName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startDate"))) {
			map.put("startDate", map.get("startDate").replaceAll("-", ""));
			sql.append(" and ah.date >= :startDate ");
		}
		if (StringUtils.isNotBlank(map.get("endDate"))) {
			map.put("endDate", map.get("endDate").replaceAll("-", ""));
			sql.append(" and ah.date <= :endDate ");
		}
		sql.append(" order by ah.date desc ");
		return dao.getPageMapList(sql.toString(), map, page);
	}

	@Override
	public Pagination getAnaByArea(Pagination page) {
		StringBuffer sql = new StringBuffer()
		.append("select t.area_id,t.area_name,t.total_amount,t.base_amount,t.nonbase_amount,")
		.append("t.base_ratio,t.del_amount,t.del_ration,t.ret_amount,t.ret_ratio,t.date ")
		.append(" from ana_area t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startDay"))){
			sql.append(" and t.date >= :startDay");
			params.put("startDay", map.get("startDay"));
		}
		if (StringUtils.isNotBlank(map.get("endDay"))){
			sql.append(" and t.date <= :endDay");
			params.put("endDay", map.get("endDay"));
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	@Override
	public Pagination getAnaCompinfoByArea(Pagination page) {
		StringBuffer sql = new StringBuffer()
		.append("select t.area_id,t.area_name,t.del_comp_code,t.del_comp_name,t.total_amount,t.base_amount,t.nonbase_amount,")
		.append("t.base_ratio,t.del_amount,t.del_ratio,t.ret_amount,t.ret_ratio,t.date ")
		.append(" from ana_compinfo_area t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startDay"))){
			sql.append(" and t.date >= :startDay");
			params.put("startDay", map.get("startDay"));
		}
		if (StringUtils.isNotBlank(map.get("endDay"))){
			sql.append(" and t.date <= :endDay");
			params.put("endDay", map.get("endDay"));
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	/**
	 * 
	 *@category 获取药品采购统计,跳向按地区查询数据
	 *@author 邱磊
	 *@date 2015年12月3日 上午10:06:50
	 *@param 
	 *@return Pagination
	 */
	public Pagination getAnaByAreaWithYear(Pagination page){
		StringBuffer sql = new StringBuffer()
		.append(" select t.area_name,t.date, ")
		.append(" t.total_amount/10000 total_amount,t.ret_amount/10000 ret_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount,t.eastern_ratio,t.pro_count, ")
		.append(" t.del_count,t.del_amount/10000 del_amount,t.recp_count,t.recp_amount/10000 recp_amount, ")
		.append(" t.ret_ratio,t.recp_ratio,t.del_ratio,t.area_id ")
		.append(" from ana_area_year t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(map.get("areaId"))) {
			params.put("areaId", map.get("areaId"));
			sql.append(" and t.area_id like :areaId ");
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startYear"))){
			sql.append(" and t.date >= :startYear");
			params.put("startYear", map.get("startYear"));
		}
		if (StringUtils.isNotBlank(map.get("endYear"))){
			sql.append(" and t.date <= :endYear");
			params.put("endYear", map.get("endYear"));
		}
		sql.append(" order by t.date desc ");
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	public Pagination getAnaCompinfoByAreaWithYear(Pagination page){
		StringBuffer sql = new StringBuffer()
		.append(" select t.area_id,t.area_name,t.date, ")
		.append(" t.total_amount/10000 total_amount,t.ret_amount/10000 ret_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount,t.eastern_ratio,t.pro_count, ")
		.append(" t.del_count,t.del_amount/10000 del_amount,t.recp_count,t.recp_amount/10000 recp_amount, ")
		.append(" t.ret_ratio,t.recp_ratio,t.del_ratio ")
		.append(" from ana_compinfo_area_year t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startYear"))){
			sql.append(" and t.date >= :startYear");
			params.put("startYear", map.get("startYear"));
		}
		if (StringUtils.isNotBlank(map.get("endYear"))){
			sql.append(" and t.date <= :endYear");
			params.put("endYear", map.get("endYear"));
		}
		if (StringUtils.isNotBlank(map.get("compCode"))){
			sql.append(" and t.del_comp_code = :compCode");
			params.put("compCode", map.get("compCode"));
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	
	public Pagination getAnaByAreaWithSea(Pagination page){
		StringBuffer sql = new StringBuffer()
		.append(" select t.area_name,t.date, ")
		.append(" t.total_amount/10000 total_amount,t.ret_amount/10000 ret_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount,t.eastern_ratio,t.pro_count, ")
		.append(" t.del_count,t.del_amount/10000 del_amount,t.recp_count,t.recp_amount/10000 recp_amount, ")
		.append(" t.ret_ratio,t.recp_ratio,t.del_ratio,t.area_id ")
		.append(" from ana_area_sea t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaId"))) {
			params.put("areaId", map.get("areaId"));
			sql.append(" and t.area_id like :areaId ");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startSea"))){
			sql.append(" and t.date >= :startSea");
			params.put("startSea", map.get("startSea"));
		}
		if (StringUtils.isNotBlank(map.get("endSea"))){
			sql.append(" and t.date <= :endSea");
			params.put("endSea", map.get("endSea"));
		}
		sql.append(" order by t.date desc ");
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	public Pagination getAnaCompinfoByAreaWithSea(Pagination page){
		StringBuffer sql = new StringBuffer()
		.append(" select t.area_id,t.area_name,t.date, ")
		.append(" t.total_amount/10000 total_amount,t.ret_amount/10000 ret_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount,t.eastern_ratio,t.pro_count, ")
		.append(" t.del_count,t.del_amount/10000 del_amount,t.recp_count,t.recp_amount/10000 recp_amount, ")
		.append(" t.ret_ratio,t.recp_ratio,t.del_ratio ")
		.append(" from ana_compinfo_area_sea t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startSea"))){
			sql.append(" and t.date >= :startSea");
			params.put("startSea", map.get("startSea"));
		}
		if (StringUtils.isNotBlank(map.get("endSea"))){
			sql.append(" and t.date <= :endSea");
			params.put("endSea", map.get("endSea"));
		}
		if (StringUtils.isNotBlank(map.get("compCode"))){
			sql.append(" and t.del_comp_code = :compCode");
			params.put("compCode", map.get("compCode"));
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	
	
	public Pagination getAnaByAreaWithMon(Pagination page){
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select t.area_name,t.date,t.area_id, ");
		
		if (StringUtils.isNotBlank(map.get("startMon")) || StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" sum(t.total_amount/10000) total_amount,sum(t.ret_amount/10000) ret_amount,sum(t.western_amount/10000) western_amount,sum(t.eastern_amount/10000) eastern_amount,sum(t.eastern_amount)/sum(t.total_amount) eastern_ratio,sum(t.pro_count) pro_count,sum(t.del_count) del_count,sum(t.del_amount/10000) del_amount,sum(t.recp_count) recp_count,sum(t.recp_amount/10000) recp_amount,sum(t.ret_amount)/sum(t.total_amount) ret_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
		}else {
			sql.append(" t.total_amount/10000 total_amount,t.ret_amount/10000 ret_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount,t.eastern_ratio,t.pro_count,t.del_count,t.del_amount/10000 del_amount,t.recp_count,t.recp_amount/10000 recp_amount,t.ret_ratio,t.recp_ratio,t.del_ratio ");
		}
		
		sql.append(" from ana_area_mon t")
		.append(" where 1=1");
		
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaId"))) {
			params.put("areaId", map.get("areaId"));
			sql.append(" and t.area_id like :areaId ");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		
		if (StringUtils.isNotBlank(map.get("endMon"))){
			sql.append(" and t.date <= :endMon");
			params.put("endMon", map.get("endMon"));
		}
		
		if (StringUtils.isNotBlank(map.get("startMon")) && !StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and t.date >= :startMon");
			params.put("startMon", map.get("startMon"));
			sql.append(" group by t.area_id");
		}else if (StringUtils.isNotBlank(map.get("areaId"))){
			if (StringUtils.isNotBlank(map.get("startMon"))){
				sql.append(" and t.date >= :startMon");
				params.put("startMon", map.get("startMon"));
			}else {
				sql.append(" group by t.date ");
			}
		}
		sql.append(" order by t.date desc ");
		if(StringUtils.isNotBlank(map.get("NoPage"))) {
			page.setRows(dao.getSqlMapList(sql.toString(), params));
			return page;
		}else {
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		
	}
	
	
	public Pagination getAnaCompinfoByAreaWithMon(Pagination page){
		String delCompCode = page.getConditions().get("delCompCode");
		String date = page.getConditions().get("date");
		String area1 = page.getConditions().get("area1");
		String area2 = page.getConditions().get("area2");
		String area3 = page.getConditions().get("area3");
		StringBuffer sql = new StringBuffer();
		if(date.split("-").length>1){
			sql.append(" select t.area_id,t.area_name, ")
			.append(" sum(t.total_amount/10000) total_amount,sum(t.ret_amount/10000) ret_amount,sum(t.western_amount/10000) western_amount,sum(t.eastern_amount/10000) eastern_amount,sum(t.eastern_amount)/sum(t.total_amount) eastern_ratio,sum(t.pro_count) pro_count, ")
			.append(" sum(t.del_count) del_count,sum(t.del_amount/10000) del_amount,sum(t.recp_count) recp_count,sum(t.recp_amount/10000) recp_amount, ")
			.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio ")
			.append(" from ana_compinfo_area_mon t")
			.append(" where t.del_comp_code = :delCompCode ");
			
		}else{
			sql.append(" select t.area_id,t.area_name, ")
			.append(" t.total_amount/10000 total_amount,t.ret_amount/10000 ret_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount,t.eastern_ratio,t.pro_count, ")
			.append(" t.del_count,t.del_amount/10000 del_amount,t.recp_count,t.recp_amount/10000 recp_amount, ")
			.append(" t.ret_ratio,t.recp_ratio,t.del_ratio ")
			.append(" from ana_compinfo_area_mon t")
			.append(" where t.del_comp_code = :delCompCode ");
		}
		
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("delCompCode", delCompCode);
		String areaId = AreaUtil.getAreaStartCode(area1,area2,area3);
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", areaId+ "%");
		}
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2 group by t.area_id ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date ");
			params.put("date", date);
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	/**
	 * @category 按医院统计(年)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getYearAnaByHosp(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select * from ana_hospital_year ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("hospName"))) {
			sql.append(" and (ah.hosp_name like :hospName or ah.hosp_spel_code like :hospName )");
			map.put("hospName", "%"+map.get("hospName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("starttime"))) {
			sql.append(" and ah.date >= :starttime ");
		}
		if (StringUtils.isNotBlank(map.get("endtime"))) {
			sql.append(" and ah.date <= :endtime ");
		}
		if (StringUtils.isNotBlank(map.get("areaId"))) {
			map.put("areaId", map.get("areaId"));
			sql.append(" and ah.hosp_area_id like :areaId ");
		}
		sql.append(" order by ah.date desc ");
		return dao.getPageMapList(sql.toString(), map, page);
	}
	
	
	/**
	 * @category 按医院统计(季度)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getSeaAnaByHosp(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select * from ana_hospital_sea ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("hospName"))) {
			sql.append(" and (ah.hosp_name like :hospName or ah.hosp_spel_code like :hospName )");
			map.put("hospName", "%"+map.get("hospName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("starttime"))) {
			map.put("starttime", map.get("starttime").replaceAll("年", "0").replaceAll("季度", ""));
			sql.append(" and ah.date >= :starttime ");
		}
		if (StringUtils.isNotBlank(map.get("endtime"))) {
			map.put("endtime", map.get("endtime").replaceAll("年", "0").replaceAll("季度", ""));
			sql.append(" and ah.date <= :endtime ");
		}
		if (StringUtils.isNotBlank(map.get("areaId"))) {
			map.put("areaId", map.get("areaId"));
			sql.append(" and ah.hosp_area_id like :areaId ");
		}
		sql.append(" order by ah.date desc ");
		return dao.getPageMapList(sql.toString(), map, page);
	}
	
	/**
	 * @category 按医院统计(月)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getMonthAnaByHosp(Pagination page) {
		Map<String, String> map =new HashMap<String, String>(); 
		StringBuffer sql =new StringBuffer();
		String hospClassifys = page.getConditions().get("hospClassifys");
		String hospType = page.getConditions().get("hospType");
		String hospName = page.getConditions().get("hospName");
		
		sql.append(" select ah.hosp_name,ah.hosp_code,ah.date,ah.hosp_area_id,ah.hosp_ar_fullname,ah.hosp_level_id,ah.hosp_classify, ");
		if (StringUtils.isNotBlank(map.get("startMon"))){
			sql.append(" sum(ah.total_amount/10000) total_amount,sum(ah.western_amount/10000) western_amount,sum(ah.eastern_amount/10000) eastern_amount,ah.eastern_ratio,sum(ah.del_amount/10000) del_amount,sum(ah.del_ratio) del_ratio,sum(ah.recp_amount/10000) recp_amount,sum(ah.recp_ratio) recp_ratio ");
		}else {
			sql.append(" ah.total_amount/10000 total_amount,ah.western_amount/10000 western_amount,ah.eastern_amount/10000 eastern_amount,ah.eastern_ratio,ah.del_amount/10000 del_amount,ah.del_ratio,ah.recp_amount/10000 recp_amount,ah.recp_ratio ");
		}
		sql.append(" from ana_hospital_mon ah")
		   .append(" where 1=1");
		String areaId = page.getConditions().get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = page.getConditions().get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = page.getConditions().get("area1");
			}
		}
		areaId = StringUtils.isNotBlank(areaId)?(AreaUtil.getAreaPrefix(areaId)+"%"):page.getConditions().get("areaId");
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and ah.hosp_area_id like :areaId");
			map.put("areaId", areaId);
		}
//		if (StringUtils.isNotBlank(page.getConditions().get("areaName"))){
//			sql.append(" and ah.hosp_area_id like :areaName");
//			map.put("areaName", "%" + page.getConditions().get("areaName").trim() + "%");
//		}
		if (StringUtils.isNotBlank(page.getConditions().get("hospName"))) {
			sql.append(" and (ah.hosp_name like :hospName or ah.hosp_spel_code like :hospName )");
			map.put("hospName", "%"+hospName.trim()+"%");
		}
		if(hospClassifys != null && hospClassifys !=""){
			map.put("hospClassifys", page.getConditions().get("hospClassifys"));
			sql.append(" and ah.hosp_classify = :hospClassifys ");
		}
		if(hospType != null && hospType !=""){
			map.put("hospType", page.getConditions().get("hospType"));
			sql.append(" and ah.hosp_level_id = :hospType ");
		}
		if (StringUtils.isNotBlank(page.getConditions().get("endMon"))){
			sql.append(" and ah.date <= :endMon");
			map.put("endMon", page.getConditions().get("endMon").replace("-",""));
		}
		if (StringUtils.isNotBlank(page.getConditions().get("startMon"))){
			sql.append(" and ah.date >= :startMon");
			map.put("startMon", page.getConditions().get("startMon").replace("-",""));
			sql.append(" group by ah.hosp_name ");
		}
		sql.append(" order by ah.date desc ");
		if(StringUtils.isNotBlank(page.getConditions().get("Paging"))){
			return dao.getSqlPageMapList(sql.toString(), map, page);
		}
		page.setRows(dao.getSqlMapList(sql.toString(),  map)); 
		return page;
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaTotalByTime() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select adt.ana_id,adt.is_basic,adt.total_a"
				+ "mount,adt.del_amount,adt.ret_amount,")
		.append("adt.date from ana_druginfo_total adt where :date <= adt.date")
		.append(" ORDER BY adt.date");
		
		map.put("date", ParseDate.parseDateToYmd(ParseDate.addDate(new Date(), -7)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取药品采购月汇总信息
	 * @date 2015-12-3
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaByDrugsMonth(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select adm.*,bgi.qualityspec_name drug_name,bgi.qualityspec_name_spel,bgi.form_name,bgi.spec_name, ")
		.append(" bgi.factor,bgi.unit_name,bgi.prod_compname,bgi.prod_compcode ")
		.append(" from ana_druginfo_mon adm  join ")
		.append(" ( select distinct drug_code,qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on bgi.drug_code =adm.drug_code where 1=1  ");
		
		if(StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and adm.area_id like :areaId ");
			sql = new StringBuffer(sql.toString().replace("ana_druginfo_mon", "ana_areadruginfo_total_mon"));
		}
		
		if(StringUtils.isNotBlank(map.get("drug_name"))){
			sql.append(" and (bgi.qualityspec_name like :drug_name OR bgi.qualityspec_name_spel like :drug_name )");
			map.put("drug_name", "%" + map.get("drug_name").trim() + "%");
		}
		
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and adm.drug_cat in ("+map.get("drugCat")+") ");
			map.remove("drugCat");
		}
		sql.append(" ORDER BY adm.date desc ");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			map.remove("Paging");
			return dao.getSqlPageMapList(sql.toString(), map, page);
		}
		map.remove("Paging");
		page.setRows(dao.getSqlMapList(sql.toString(), map)); 
		return page;
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByAllMonth(Pagination page) {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select IFNULL(admt.drug_cat,'') drug_cat,sum(IFNULL(admt.total_amount/10000,'')) total_amount,")
		.append("sum(admt.del_amount/10000) del_amount,sum(admt.recp_amount/10000) recp_amount,admt.date from ana_druginfo_mon_total admt where 1=1 ");
		
		if(StringUtils.isNotBlank(page.getConditions().get("starttime"))){
			sql.append(" AND admt.date >= :starttime");
			map.put("starttime", page.getConditions().get("starttime"));
			
		}else {
			sql.append(" AND :date <= admt.date");
			map.put("date", ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -7)));
		}
		if(StringUtils.isNotBlank(page.getConditions().get("endtime"))){
			sql.append(" AND admt.date <= :endtime ");
			map.put("endtime", page.getConditions().get("endtime"));
		}
		
		sql.append(" group by admt.date order by admt.date");
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取药品采购季度汇总信息
	 * @date 2015-12-3
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaByDrugsSea(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ads.*,bgi.qualityspec_name drug_name,bgi.form_name,bgi.spec_name, ")
		.append(" bgi.factor,bgi.unit_name,bgi.prod_compname,bgi.prod_compcode ")
		.append(" from ana_druginfo_season ads  join ")
		.append(" ( select distinct drug_code,qualityspec_name,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item  ) bgi on bgi.drug_code =ads.drug_code where 1=1  ");
		
		if(StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and ads.area_id like :areaId ");
			sql = new StringBuffer(sql.toString().replace("ana_druginfo_season", "ana_areadruginfo_total_sea"));
		}
		if(StringUtils.isNotBlank(map.get("starttime"))){
			map.put("starttime", map.get("starttime").replace("年", "0").replace("季度", ""));
			sql.append(" AND date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			map.put("endtime", map.get("endtime").replace("年", "0").replace("季度", ""));
			sql.append(" AND date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("isBasic"))){
			sql.append(" and ads.is_basic=:isBasic ");
		}
		if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and ads.drug_cat in ("+map.get("drugCat")+") ");
			map.remove("drugCat");
		}
		sql.append(" ORDER BY ads.date  desc");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}
	
	/**
	 * @category 前七个季度总体情况
	 * @date 2015-12-22
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByAllSea() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select IFNULL(admt.drug_cat,'') drug_cat,IFNULL(admt.total_amount/10000,'') total_amount,")
		.append("IFNULL(admt.pro_count,'') pro_count,admt.date from ana_druginfo_total_sea admt where :date <= admt.date")
		.append(" ORDER BY admt.date");
		
		map.put("date", ParseDate.getSea(ParseDate.addMonth(new Date(), -21)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取药品采购年汇总信息
	 * @date 2015-12-3
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaByDrugsYear(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ady.*,bgi.qualityspec_name drug_name,bgi.form_name,bgi.spec_name, ")
		.append(" bgi.factor,bgi.unit_name,bgi.prod_compname,bgi.prod_compcode ")
		.append(" from ana_druginfo_year ady  join ")
		.append(" ( select distinct drug_code,qualityspec_name,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item  ) bgi on bgi.drug_code =ady.drug_code where 1=1  ");
		
		if(StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and ady.area_id like :areaId ");
			sql = new StringBuffer(sql.toString().replace("ana_druginfo_year", "ana_areadruginfo_total_year"));
		}
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND ady.date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND ady.date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and ady.drug_cat in ("+map.get("drugCat")+") ");
			map.remove("drugCat");
		}
		sql.append(" ORDER BY ady.date  desc");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}
	
	/**
	 * @category 前七年总体采购情况
	 * @date 2015年12月22日
	 * @author lil
	 * @param page
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByAllYear() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select IFNULL(admt.drug_cat,'') drug_cat,IFNULL(admt.total_amount/10000,'') total_amount,")
		.append("IFNULL(admt.pro_count,'') pro_count,admt.date from ana_druginfo_total_year admt where :date <= admt.date")
		.append(" order BY admt.date");
		
		map.put("date", ParseDate.parseShortYearFormat(ParseDate.addYear(new Date(), -7)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按医院统计(年)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalLastYear(Pagination page){
		Map<String, Object> map = new HashMap<String, Object>();
		String lastYear = "";
		if (StringUtils.isNotBlank(page.getConditions().get("starttime"))) {
			lastYear = page.getConditions().get("starttime");
		}else {
			lastYear = (Calendar.getInstance().get(Calendar.YEAR)-1)+"";
		}
		StringBuffer sql = new StringBuffer()
		.append("select * from ana_hospital_year where date = :lastYear ");
		if (StringUtils.isNotBlank(page.getConditions().get("areaId"))) {
			map.put("areaId", page.getConditions().get("areaId"));
			sql.append(" and hosp_area_id like :areaId ");
		}
		sql.append(" order by total_amount desc limit 10 ");
		
		map.put("lastYear", lastYear);
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按医院统计(日)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalYesterday(){
		StringBuffer sql = new StringBuffer()
		.append("select hosp_code,hosp_name,base_amount,nonbase_amount,total_amount/10000 total_amount,base_ratio,del_amount/10000 del_amount,ret_amount/10000 ret_amount,")
		.append("del_ratio,ret_ratio,date from ana_hospital where date = :yesterday order by total_amount desc limit 10");
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("yesterday", DateUtil.date(new Timestamp(System.currentTimeMillis()-1000 * 60 * 60 * 24)).replaceAll("-", ""));
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按医院统计(月)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalLastMonth(Pagination page){
		Map<String, Object> map = new HashMap<String, Object>();
		String startMonth = "";
		if (StringUtils.isNotBlank(page.getConditions().get("starttime"))) {
			startMonth = page.getConditions().get("starttime").replaceAll("-", "");
		}else {
			startMonth = ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1));
		}
		
		StringBuffer sql = new StringBuffer()
		.append("select * from ana_hospital_mon where date = :lastMonth  ");

		if (StringUtils.isNotBlank(page.getConditions().get("areaId"))) {
			map.put("areaId", page.getConditions().get("areaId"));
			sql.append(" and hosp_area_id like :areaId ");
		}
		sql.append(" order by total_amount desc limit 10 ");
		map.put("lastMonth", startMonth);
		return dao.getSqlMapList(sql.toString(), map);
	}
	/**
	 * @category 按医院统计(月)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalLastMonths(Pagination page){
		Map<String, Object> map = new HashMap<String, Object>();
		String startMonth = "";
		if (StringUtils.isNotBlank(page.getConditions().get("starttime"))) {
			startMonth = page.getConditions().get("starttime").replaceAll("-", "");
		}else {
			startMonth = ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1));
		}
		
		StringBuffer sql = new StringBuffer()
		.append("select * from ana_hospital_mon where date = :lastMonth  ");

		if (StringUtils.isNotBlank(page.getConditions().get("areaId"))) {
			map.put("areaId", page.getConditions().get("areaId"));
			sql.append(" and hosp_area_id like :areaId ");
		}
		sql.append(" order by total_amount desc limit 10 ");
		map.put("lastMonth", startMonth);
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按医院统计(季)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalLastQuarter(Pagination page){
		Map<String, Object> map = new HashMap<String, Object>();
		String lastQuarter = "";
		if (StringUtils.isNotBlank(page.getConditions().get("starttime"))) {
			lastQuarter = page.getConditions().get("starttime").replaceAll("年", "0").replaceAll("季度", "");
		}else {
			lastQuarter = ParseDate.getSea(ParseDate.addMonth(new Date(), -3));
		}
		StringBuffer sql = new StringBuffer()
		.append("select * from ana_hospital_sea where date = :lastQuarter  ");
		if (StringUtils.isNotBlank(page.getConditions().get("areaId"))) {
			map.put("areaId", page.getConditions().get("areaId"));
			sql.append(" and hosp_area_id like :areaId ");
		}
		sql.append(" order by total_amount desc limit 10 ");
		map.put("lastQuarter", lastQuarter);
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按企业统计(日)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getAnaByComp(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.del_comp_code,ah.del_comp_name,ah.date, ")
		.append(" ah.total_amount,ah.base_amount,ah.nonbase_amount,ah.ret_amount, ")
		.append(" ah.base_ratio, ")
		.append(" ah.ret_ratio ")
		.append("  from ana_compinfo ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("delCompName"))) {
			sql.append(" and (ah.del_comp_name like :delCompName or ah.del_comp_name_spel like :delCompName )");
			map.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startDate"))) {
			map.put("startDate", map.get("startDate").replaceAll("-", ""));
			sql.append(" and ah.date >= :startDate ");
		}
		if (StringUtils.isNotBlank(map.get("endDate"))) {
			map.put("endDate", map.get("endDate").replaceAll("-", ""));
			sql.append(" and ah.date <= :endDate ");
		}
		sql.append(" order by ah.date desc ");
		return dao.getPageMapList(sql.toString(), map, page);
	}



	/**
	 * @category 按企业统计(年)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getYearAnaByComp(Pagination page) {
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.del_comp_code,ah.del_comp_name,ah.date, ")
		.append(" ah.total_amount/10000 total_amount,ah.ret_amount/10000 ret_amount,ah.western_amount/10000 western_amount,ah.eastern_amount/10000 eastern_amount,ah.eastern_ratio,ah.pro_count, ")
		.append(" ah.del_count,ah.del_amount/10000 del_amount,ah.recp_count,ah.recp_amount/10000 recp_amount, ")
		.append(" ah.ret_ratio,ah.recp_ratio,del_ratio ")
		.append("  from ana_compinfo_year ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("delCompName"))) {
			sql.append(" and (ah.del_comp_name like :delCompName or ah.del_comp_name_spel like :delCompName )");
			params.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startYear"))) {
			sql.append(" and ah.date >= :startYear ");
			params.put("startYear", map.get("startYear"));
		}
		if (StringUtils.isNotBlank(map.get("endYear"))) {
			sql.append(" and ah.date <= :endYear ");
			params.put("endYear", map.get("endYear"));
		}
		if (StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and ah.area_id like :areaId ");
			params.put("areaId", map.get("areaId"));
			String strSql = sql.toString().replace("ana_compinfo_year", "ana_compinfo_area_year");
			sql.delete(0, sql.length());
			sql.append(strSql);
		}
		sql.append(" order by ah.date desc ");
		return dao.getPageMapList(sql.toString(), params, page);
	}
	
	
	/**
	 * @category 按企业统计(季度)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getSeaAnaByComp(Pagination page) {
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.del_comp_code,ah.del_comp_name,ah.date, ")
		.append(" ah.total_amount/10000 total_amount,ah.ret_amount/10000 ret_amount,ah.western_amount/10000 western_amount,ah.eastern_amount/10000 eastern_amount,ah.eastern_ratio,ah.pro_count, ")
		.append(" ah.del_count,ah.del_amount/10000 del_amount,ah.recp_count,ah.recp_amount/10000 recp_amount, ")
		.append(" ah.ret_ratio,ah.recp_ratio,del_ratio ")
		.append("  from ana_compinfo_sea ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("delCompName"))) {
			sql.append(" and (ah.del_comp_name like :delCompName or ah.del_comp_name_spel like :delCompName )");
			params.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startSea"))) {
			params.put("startSea", map.get("startSea").replaceAll("年", "0").replaceAll("季度", ""));
			sql.append(" and ah.date >= :startSea ");
		}
		if (StringUtils.isNotBlank(map.get("endSea"))) {
			params.put("endSea", map.get("endSea").replaceAll("年", "0").replaceAll("季度", ""));
			sql.append(" and ah.date <= :endSea ");
		}
		if (StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and ah.area_id like :areaId ");
			params.put("areaId", map.get("areaId"));
			String strSql = sql.toString().replace("ana_compinfo_sea", "ana_compinfo_area_sea");
			sql.delete(0, sql.length());
			sql.append(strSql);
		}
		sql.append(" order by ah.date desc ");
		return dao.getPageMapList(sql.toString(), params, page);
	}
	
	/**
	 * @category 按企业统计(月)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getMonthAnaByComp(Pagination page) {
		String areaId = page.getConditions().get("areaId");
		if(StringUtils.isNotBlank(areaId)){
			return getWsjMonthAnaByComp(page);
		}
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.del_comp_code,ah.del_comp_name, ");
		
		if (StringUtils.isNotBlank(map.get("startMonth"))){
			sql.append(" sum(ah.total_amount/10000) total_amount,sum(ah.ret_amount/10000) ret_amount,sum(ah.western_amount/10000) western_amount,sum(ah.eastern_amount/10000) eastern_amount,sum(ah.eastern_amount)/sum(ah.total_amount) eastern_ratio,sum(ah.pro_count) pro_count, ")
			.append(" sum(ah.del_count) del_count,sum(ah.del_amount/10000) del_amount,sum(ah.recp_count) recp_count,sum(ah.recp_amount/10000) recp_amount, ")
			.append(" sum(ah.ret_amount)/sum(ah.total_amount) ret_ratio,sum(recp_amount)/sum(ah.total_amount) recp_ratio,sum(ah.del_amount)/sum(ah.total_amount) del_ratio ");
			
		}else {
			sql.append(" ah.date,ah.total_amount/10000 total_amount,ah.ret_amount/10000 ret_amount,ah.western_amount/10000 western_amount,ah.eastern_amount/10000 eastern_amount,ah.eastern_ratio,ah.pro_count, ")
			.append(" ah.del_count,ah.del_amount/10000 del_amount,ah.recp_count,ah.recp_amount/10000 recp_amount, ")
			.append(" ah.ret_ratio,ah.recp_ratio,del_ratio ");
			
		}
		
		sql.append("  from ana_compinfo_mon ah where 1=1  ");
		
		
		if (StringUtils.isNotBlank(map.get("delCompName"))) {
			sql.append(" and (ah.del_comp_name like :delCompName or ah.del_comp_name_spel like :delCompName )");
			params.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		
		if (StringUtils.isNotBlank(map.get("endMonth"))) {
			params.put("endMonth", map.get("endMonth").replaceAll("-", ""));
			sql.append(" and ah.date <= :endMonth ");
		}
		if (StringUtils.isNotBlank(map.get("startMonth"))) {
			params.put("startMonth", map.get("startMonth").replaceAll("-", ""));
			sql.append(" and ah.date >= :startMonth ");
			sql.append(" group by ah.del_comp_code");
		}
		sql.append(" order by ah.date desc ");
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	/**
	 * @category 按企业统计(年)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalByCompLastYear(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		
		String lastYear = "";
		if (StringUtils.isNotBlank(map.get("startYear"))) {
			lastYear = map.get("startYear");
		}else {
			lastYear = (Calendar.getInstance().get(Calendar.YEAR)-1)+"";
		}
		StringBuffer sql = new StringBuffer()
		.append("select del_comp_name,total_amount/10000 total_amount,date ")
		.append(" from ana_compinfo_year where date = :lastYear ");
		if (StringUtils.isNotBlank(map.get("areaId"))){
			String areaId = map.get("areaId");
			sql.append(" and area_id like :areaId ");
			
			String strSql = sql.toString().replace("ana_compinfo_year", "ana_compinfo_area_year");
			sql.delete(0, sql.length());
			sql.append(strSql);
			map.clear();
			map.put("areaId", areaId);
			
		}else {
			map.clear();
		}
		sql.append(" order by total_amount desc  limit 10");
		
		map.put("lastYear", lastYear);
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按企业统计(日)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalByCompYesterday(){
		StringBuffer sql = new StringBuffer()
		.append("select del_comp_code,del_comp_name,base_amount,nonbase_amount,total_amount/10000 total_amount,base_ratio,del_amount/10000 del_amount,ret_amount/10000 ret_amount,")
		.append("del_ratio,ret_ratio,date from ana_compinfo where date = :yesterday order by total_amount desc limit 10");
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("yesterday", DateUtil.date(new Timestamp(System.currentTimeMillis()-1000 * 60 * 60 * 24)).replaceAll("-", ""));
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按企业统计(月)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalByCompLastMonth(Pagination page){
		Map<String, String> map = new HashMap<String, String>();
		
		String startMon = page.getConditions().get("startMon");
		StringBuffer sql = new StringBuffer();
		
		if (StringUtils.isNotBlank(page.getConditions().get("areaId"))){
			sql.append("select del_comp_name,sum(total_amount/10000) total_amount,date ")
			.append(" from ana_compinfo_area_mon where date = :lastMonth and area_id like :areaId group by del_comp_code order by sum(total_amount) ");
			String areaId = page.getConditions().get("areaId");
			map.put("areaId", areaId);
			
		}else {
			sql.append("select del_comp_name,total_amount/10000 total_amount,date ")
			.append(" from ana_compinfo_mon where date = :lastMonth order by total_amount ");
		}
		sql.append("  desc  limit 10");
		
		map.put("lastMonth", startMon);
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 按企业统计(季)柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getAnaTotalByCompLastQuarter(Pagination page){
		Map<String, String> map =page.getConditions();
		String lastQuarter = "";
		if (StringUtils.isNotBlank(map.get("startSea"))) {
			lastQuarter = map.get("startSea").replaceAll("年", "0").replaceAll("季度", "");
		}else {
			lastQuarter = ParseDate.getSea(ParseDate.addMonth(new Date(), -3));
		}
		
		StringBuffer sql = new StringBuffer()
		.append("select del_comp_name,total_amount/10000 total_amount,date ")
		.append(" from ana_compinfo_sea where date = :lastQuarter ");
		if (StringUtils.isNotBlank(map.get("areaId"))){
			String areaId = map.get("areaId");
			sql.append(" and area_id like :areaId ");
			
			String strSql = sql.toString().replace("ana_compinfo_sea", "ana_compinfo_area_sea");
			sql.delete(0, sql.length());
			sql.append(strSql);
			map.clear();
			map.put("areaId", areaId);
		}else {
			map.clear();
		}
		sql.append(" order by total_amount desc  limit 10");
		
		map.put("lastQuarter", lastQuarter);
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 首页的柱状图数据
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public List<?> getHomeChartData(){
		StringBuffer sql = new StringBuffer()
		.append("select is_basic,total_amount/10000 total_amount,del_amount/10000 del_amount,ret_amount/10000 ret_amount,")
		.append("date from ana_druginfo_mon_total where date < :lastMonth order by date limit 6");
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("lastMonth", ParseDate.parseDateToYm(new Date()));
		return dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取药品采购总量日汇总列表信息
	 * @date 2015-12-3
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@Override
	public Pagination getAnaListByTime(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append("select adt.ana_id,adt.is_basic,adt.total_amount,adt.del_amount,adt.ret_amount,")
		.append("adt.date,adt.ret_ratio,adt.del_ratio from ana_druginfo_total adt  where 1=1  ");
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND adt.date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND adt.date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("isBasic"))){
			sql.append(" and adt.is_basic=:isBasic ");
		}
		sql.append(" ORDER BY adt.date desc ");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}
	
	/**
	 * @category 采购总体情况汇总信息（月度）
	 * @date 2015-12-3
	 * @author lil
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaByAllMonth(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		Map<String, Object> params = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select admt.ana_id,admt.is_basic,admt.drug_cat,");
				
		/*if(StringUtils.isNotBlank(map.get("starttime"))){*/
			sql.append("sum(admt.pro_count) pro_count,sum(admt.total_amount/10000) total_amount,sum(admt.recp_amount/10000) recp_amount,sum(admt.del_amount/10000) del_amount,sum(admt.ret_amount/10000) ret_amount,sum(admt.ret_amount)/sum(admt.total_amount) ret_ratio,sum(admt.del_amount)/sum(admt.total_amount) del_ratio,sum(admt.recp_amount)/sum(admt.total_amount) recp_ratio,");
		/*}else {
			sql.append("admt.pro_count,admt.total_amount/10000 total_amount,admt.recp_amount/10000 recp_amount,admt.del_amount/10000 del_amount,admt.ret_amount/10000 ret_amount,admt.ret_ratio,admt.del_ratio,admt.recp_ratio,");
		}*/
		sql.append("admt.date from ana_druginfo_mon_total admt where 1=1");
		
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND admt.date <= :endtime ");
			params.put("endtime", map.get("endtime"));
		}
		if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and admt.drug_cat in ("+map.get("drugCat")+") ");
		}
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND admt.date >= :starttime ");
			params.put("starttime", map.get("starttime"));
			
		}else {
			sql.append(" GROUP BY admt.date ");
		}
		sql.append(" ORDER BY admt.date desc ");
		if(StringUtils.isNotBlank(map.get("NoPage"))) {
			page.setRows(dao.getSqlMapList(sql.toString(), params));
			return page;
		}else {
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		
	}
	
	/**
	 * @category 采购总体情况汇总信息（季度）
	 * @date 2015-12-22
	 * @author lil
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaByAllSea(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append("select adts.ana_id,adts.is_basic,adts.drug_cat,adts.total_amount/10000 total_amount,adts.recp_amount/10000 recp_amount,adts.del_amount/10000 del_amount,adts.ret_amount/10000 ret_amount,")
		.append("adts.date,adts.ret_ratio,adts.del_ratio,adts.recp_ratio from ana_druginfo_total_sea adts where 1=1");
		if(StringUtils.isNotBlank(map.get("starttime"))){
			map.put("starttime", map.get("starttime").replace("年", "0").replace("季度", ""));
			sql.append(" AND adts.date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			map.put("endtime", map.get("endtime").replace("年", "0").replace("季度", ""));
			sql.append(" AND adts.date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and adts.drug_cat in ("+map.get("drugCat")+") ");
			map.remove("drugCat");
		}
		sql.append(" ORDER BY adts.date desc ");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}
	
	/**
	 * @category 采购总体情况汇总信息（年度）
	 * @date 2015年12月22日
	 * @author lil
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaByAllYear(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append("select adty.ana_id,adty.is_basic,adty.drug_cat,adty.total_amount/10000 total_amount,adty.recp_amount/10000 recp_amount,adty.del_amount/10000 del_amount,adty.ret_amount/10000 ret_amount,")
		.append("adty.date,adty.ret_ratio,adty.del_ratio,adty.recp_ratio,adty.pro_count from ana_druginfo_total_year adty where 1=1");
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND adty.date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND adty.date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and adty.drug_cat in ("+map.get("drugCat")+") ");
			map.remove("drugCat");
		}
		sql.append(" ORDER BY adty.date desc ");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}
	
	/**
	 * @category 获取地区每日销售量前十的地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByArea(Pagination page) {
		StringBuffer sql =new StringBuffer();
		sql.append("select t.area_name,t.total_amount,t.base_amount,t.nonbase_amount,t.del_amount,t.ret_amount")
		.append(" from ana_area t where t.date = :date  ");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startDay"))){
			sql.append(" and t.date >= :startDay");
			params.put("startDay", map.get("startDay"));
		}
		if (StringUtils.isNotBlank(map.get("endDay"))){
			sql.append(" and t.date <= :endDay");
			params.put("endDay", map.get("endDay"));
		}
		params.put("date", ParseDate.parseDateToYmd(ParseDate.addDate(new Date(), -1)));
		sql.append(" order by t.total_amount desc limit 10 ");
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), params);
	}
	
	/**
	 * @category 获取地区销售量前十的上一月地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByAreaWithMon(Pagination page) {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select t.area_name,t.total_amount/10000 total_amount,t.date ")
		.append(" from ana_area_mon t where t.date = :date  order by t.total_amount desc limit 10");
		
		String startMon = "";
		if (StringUtils.isNotBlank(page.getConditions().get("startMon"))){
			startMon = page.getConditions().get("startMon");
		}else {
			startMon = ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1));
		}
		map.put("date", startMon);
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	/**
	 * @category 获取地区销售量前十的上一月地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getMonthAnaByHosps(Pagination page) {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select t.hosp_name,t.total_amount/10000 total_amount,t.date ")
		.append(" from ana_hospital_mon t where t.date = :date  ");
		
		String startMon = "";
		if (StringUtils.isNotBlank(page.getConditions().get("startMon"))){
			startMon = page.getConditions().get("startMon");
		}else {
			startMon = ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1));
		}
		
		if (StringUtils.isNotBlank(page.getConditions().get("areaId"))){
			sql.append(" and t.hosp_area_id like :areaId");
			map.put("areaId", page.getConditions().get("areaId"));
		}
		sql.append(" order by t.total_amount desc limit 10");	
		
		map.put("date", startMon);
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	
	/**
	 * @category 获取地区销售量前十的上一季度地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByAreaWithSea(Pagination page) {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select t.area_name,t.total_amount/10000 total_amount,t.date ")
		.append(" from ana_area_sea t where t.date = :date  order by t.total_amount desc limit 10");
		
		String startSea = "";
		if (StringUtils.isNotBlank(page.getConditions().get("startSea"))){
			startSea = page.getConditions().get("startSea");
		}else {
			startSea = ParseDate.getSea(ParseDate.addMonth(new Date(), -3));
		}
		map.put("date", startSea);
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取地区销售量前十的上一年地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByAreaWithYear(Pagination page) {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select t.area_name,t.total_amount/10000 total_amount,t.date ")
		.append(" from ana_area_year t where t.date = :date  order by t.total_amount desc limit 10");
		
		String startYear ="";
		if (StringUtils.isNotBlank(page.getConditions().get("startYear"))){
			startYear = page.getConditions().get("startYear");
		}else {
			startYear = ParseDate.parseShortYearFormat(ParseDate.addYear(new Date(), -1));
		}
		
		map.put("date", startYear);
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	
	/**
	 * @category 获取药品每日销售量前十的地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByDrugs() {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select t.total_amount,t.del_amount,t.ret_amount,bgi.qualityspec_name drug_name ")
		.append("from ana_druginfo t left join base_goods_item bgi on bgi.drug_code =t.drug_code ")
		.append("where t.date = :date order by t.total_amount DESC limit 10");
		
		map.put("date", ParseDate.parseDateToYmd(ParseDate.addDate(new Date(), -1)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取药品销售量前十的上一月地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByDrugsMon(Pagination page) {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		if(StringUtils.isNotBlank(page.getConditions().get("areaId"))){
			sql.append("select sum(t.total_amount) total_amount,CONCAT(bgi.qualityspec_name,'/',bgi.form_name,'/',bgi.spec_name) drug_name ");
		}else {
			sql.append("select t.total_amount,CONCAT(bgi.qualityspec_name,'/',bgi.form_name,'/',bgi.spec_name) drug_name ");
		}
		
		sql.append(" from ana_druginfo_mon t  join ")
		.append(" ( select distinct drug_code,qualityspec_name,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on bgi.drug_code =t.drug_code  where t.date = :date ");
		if(StringUtils.isNotBlank(page.getConditions().get("areaId"))){
			sql.append(" and t.area_id like :areaId group by t.drug_code order by sum(t.total_amount) ");
			sql = new StringBuffer(sql.toString().replace("ana_druginfo_mon", "ana_areadruginfo_total_mon"));
			map.put("areaId", page.getConditions().get("areaId"));
		}else {
			sql.append(" order by t.total_amount ");
		}
		sql.append("  desc limit 10");
		
		map.put("date", page.getConditions().get("month"));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取药品销售量前十的上一季度地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByDrugsSea(Pagination page) {
		Map<String, Object> map = new HashMap<String, Object>();
		String lastQuarter = "";
		if (StringUtils.isNotBlank(page.getConditions().get("starttime"))) {
			lastQuarter = page.getConditions().get("starttime").replaceAll("年", "0").replaceAll("季度", "");
		}else {
			lastQuarter = ParseDate.getSea(ParseDate.addMonth(new Date(), -3));
		}
		StringBuffer sql =new StringBuffer();
		sql.append("select t.total_amount,t.del_amount,t.ret_amount,bgi.qualityspec_name drug_name ")
		.append(" from ana_druginfo_season t  join ")
		.append(" ( select distinct drug_code,qualityspec_name,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on bgi.drug_code =t.drug_code  where t.date = :date  ");
		if(StringUtils.isNotBlank(page.getConditions().get("areaId"))){
			sql.append(" and t.area_id like :areaId ");
			sql = new StringBuffer(sql.toString().replace("ana_druginfo_season", "ana_areadruginfo_total_sea"));
			map.put("areaId", page.getConditions().get("areaId"));
		}
		sql.append(" order by t.total_amount desc limit 10");
		
		map.put("date", lastQuarter);
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 获取药品销售量前十的上一年地区信息
	 * @date 2015-12-4
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaChartByDrugsYear(Pagination page) {
		Map<String, Object> map = new HashMap<String, Object>();
		String lastYear = "";
		if (StringUtils.isNotBlank(page.getConditions().get("starttime"))) {
			lastYear = page.getConditions().get("starttime");
		}else {
			lastYear = (Calendar.getInstance().get(Calendar.YEAR)-1)+"";
		}
		StringBuffer sql =new StringBuffer();
		sql.append("select t.total_amount,t.del_amount,t.ret_amount,bgi.qualityspec_name drug_name ")
		.append(" from ana_druginfo_year t  join ")
		.append(" ( select distinct drug_code,qualityspec_name,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on bgi.drug_code =t.drug_code where t.date = :date ");
		
		if(StringUtils.isNotBlank(page.getConditions().get("areaId"))){
			sql.append(" and t.area_id like :areaId ");
			sql = new StringBuffer(sql.toString().replace("ana_druginfo_year", "ana_areadruginfo_total_year"));
			map.put("areaId", page.getConditions().get("areaId"));
		}
		sql.append(" order by t.total_amount desc limit 10");
		
		map.put("date", lastYear);
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	@Override
	public Pagination getAnaByDrugsMonthPool(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer()
		.append(" select "+map.get("date")+" date,")
		.append(" a.drug_code, ")
		.append(" a.drug_cat, ")
		.append(" sum(a.total_amount) total_amount, ")
		.append(" sum(a.del_amount) del_amount, ")
		.append(" sum(a.del_amount)/sum(a.total_amount) del_ratio, ")
		.append(" sum(a.recp_amount) recp_amount, ")
		.append(" sum(a.recp_amount)/sum(a.total_amount) recp_ratio, ")
		.append(" bgi.qualityspec_name drug_name,bgi.qualityspec_name_spel,bgi.form_name,bgi.spec_name,bgi.factor,bgi.unit_name,bgi.prod_compname ")
		.append(" from ana_druginfo_mon a  join  ")
		.append(" ( select distinct drug_code,qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname from base_goods_item ) bgi on bgi.drug_code =a.drug_code  ")
		.append(" where 1=1   ");
		
		
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" and a.date >= :starttime and a.date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and a.area_id like :areaId ");
			sql = new StringBuffer(sql.toString().replace("ana_druginfo_mon", "ana_areadruginfo_total_mon"));
		}
		
		if(StringUtils.isNotBlank(map.get("drug_name"))){
			sql.append(" and (bgi.qualityspec_name like :drug_name OR bgi.qualityspec_name_spel like :drug_name )");
			map.put("drug_name", "%" + map.get("drug_name").trim() + "%");
		}
		
		if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and a.drug_cat in ("+map.get("drugCat")+") ");
			map.remove("drugCat");
		}
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" group BY a.drug_code ");
		}else {
			sql.append(" group BY a.date,a.drug_code ");
		}
		sql.append(" order by a.date desc ");
		map.remove("date");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			map.remove("Paging");
			return dao.getSqlPageMapList(sql.toString(), map, page);
		}
		map.remove("Paging");
		page.setRows(dao.getSqlMapList(sql.toString(),  map)); 
		return page;
	}

	@Override
	public Pagination getAnaByDrugsSeaNoPage(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ads.*,bgi.qualityspec_name drug_name,bgi.form_name,bgi.spec_name, ")
		.append(" bgi.factor,bgi.unit_name,bgi.prod_compname,bgi.prod_compcode ") 
		.append(" from ana_druginfo_season ads  join ")
		.append(" ( select distinct drug_code,qualityspec_name,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on bgi.drug_code =ads.drug_code where 1=1  ");
		
		if(StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and ads.area_id like :areaId ");
			sql = new StringBuffer(sql.toString().replace("ana_druginfo_season", "ana_areadruginfo_total_sea"));
		}
		if(StringUtils.isNotBlank(map.get("starttime"))){
			map.put("starttime", map.get("starttime").replace("年", "0").replace("季度", ""));
			sql.append(" AND date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			map.put("endtime", map.get("endtime").replace("年", "0").replace("季度", ""));
			sql.append(" AND date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("isBasic"))){
			sql.append(" and ads.is_basic=:isBasic ");
		}
		if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and ads.drug_cat in ("+map.get("drugCat")+") ");
			map.remove("drugCat");
		}
		sql.append(" ORDER BY ads.date  desc");
		page.setRows(dao.getSqlMapList(sql.toString(), map)); 
		return page;
	}

	
	@Override
	public Pagination getAnaByDrugsYearNoPage(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ady.*,bgi.qualityspec_name drug_name,bgi.form_name,bgi.spec_name, ")
		.append(" bgi.factor,bgi.unit_name,bgi.prod_compname,bgi.prod_compcode ")
		.append(" from ana_druginfo_year ady  join ")
		.append(" ( select distinct drug_code,qualityspec_name,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on bgi.drug_code =ady.drug_code where 1=1  ");
		if(StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and ady.area_id like :areaId ");
			sql = new StringBuffer(sql.toString().replace("ana_druginfo_year", "ana_areadruginfo_total_year"));
		}
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND ady.date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND ady.date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("isBasic"))){
			sql.append(" and ady.is_basic=:isBasic ");
		}
		if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and ady.drug_cat in ("+map.get("drugCat")+") ");
			map.remove("drugCat");
		}
		sql.append(" ORDER BY ady.date  desc");
		page.setRows(dao.getSqlMapList(sql.toString(), map)); 
		return page;
	}
	
	/**
	 * @category 采购总体情况汇总信息无分页（月度）
	 * @date 2015-12-3
	 * @author lil
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaByAllMonthNoPage(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append("select admt.ana_id,admt.is_basic,admt.drug_cat,");
				
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append("sum(admt.pro_count) pro_count,sum(admt.total_amount/10000) total_amount,sum(admt.recp_amount/10000) recp_amount,sum(admt.del_amount/10000) del_amount,sum(admt.ret_amount/10000) ret_amount,sum(admt.ret_amount)/sum(admt.total_amount) ret_ratio,sum(admt.del_amount)/sum(admt.total_amount) del_ratio,sum(admt.recp_amount)/sum(admt.total_amount) recp_ratio,");
		}else {
			sql.append("admt.pro_count,admt.total_amount/10000 total_amount,admt.recp_amount/10000 recp_amount,admt.del_amount/10000 del_amount,admt.ret_amount/10000 ret_amount,admt.ret_ratio,admt.del_ratio,admt.recp_ratio,");
		}
		sql.append("admt.date from ana_druginfo_mon_total admt where 1=1");
		
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND admt.date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and admt.drug_cat in ("+map.get("drugCat")+") ");
			map.remove("drugCat");
		}
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND admt.date >= :starttime ");
			sql.append(" GROUP BY admt.drug_cat ");
		}
		sql.append(" ORDER BY admt.date desc ");
		page.setRows(dao.getSqlMapList(sql.toString(), map)); 
		return page;
	}
	
	/**
	 * @category 采购总体情况汇总信息无分页（季度）
	 * @date 2015-12-22
	 * @author lil
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaByAllSeaNoPage(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append("select adts.ana_id,adts.is_basic,adts.drug_cat,adts.total_amount,adts.del_amount,adts.recp_amount,adts.ret_amount,")
		.append("adts.date,adts.ret_ratio,adts.del_ratio,adts.recp_ratio from ana_druginfo_total_sea adts where 1=1");
		if(StringUtils.isNotBlank(map.get("starttime"))){
			map.put("starttime", map.get("starttime").replace("年", "0").replace("季度", ""));
			sql.append(" AND adts.date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			map.put("endtime", map.get("endtime").replace("年", "0").replace("季度", ""));
			sql.append(" AND adts.date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and adts.drug_cat in ("+map.get("drugCat")+") ");
			map.remove("drugCat");
		}
		sql.append(" ORDER BY adts.date desc ");
		page.setRows(dao.getSqlMapList(sql.toString(), map)); 
		return page;
	}
	
	/**
	 * @category 采购总体情况汇总信息无分页（年度）
	 * @date 2015年12月22日
	 * @author lil
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaByAllYearNoPage(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append("select adty.ana_id,adty.is_basic,adty.drug_cat,adty.total_amount,adty.del_amount,adty.ret_amount,")
		.append("adty.recp_amount,adty.date,adty.ret_ratio,adty.del_ratio,adty.recp_ratio,adty.pro_count from ana_druginfo_total_year adty where 1=1");
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND adty.date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND adty.date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and adty.drug_cat in ("+map.get("drugCat")+") ");
			map.remove("drugCat");
		}
		sql.append(" ORDER BY adty.date desc ");
		page.setRows(dao.getSqlMapList(sql.toString(), map)); 
		return page;
	}
	
	
	/**
	 * @category 按企业统计无分页(年)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getYearAnaByCompNoPage(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.del_comp_code,ah.del_comp_name,ah.date, ")
		.append(" ah.total_amount,ah.ret_amount,ah.western_amount,ah.eastern_amount,ah.eastern_ratio,ah.pro_count, ")
		.append(" ah.del_count,ah.del_amount,ah.recp_count,ah.recp_amount, ")
		.append(" ah.ret_ratio,ah.recp_ratio,del_ratio ")
		.append("  from ana_compinfo_year ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("delCompName"))) {
			sql.append(" and (ah.del_comp_name like :delCompName or ah.del_comp_name_spel like :delCompName )");
			map.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startYear"))) {
			sql.append(" and ah.date >= :startYear ");
		}
		if (StringUtils.isNotBlank(map.get("endYear"))) {
			sql.append(" and ah.date <= :endYear ");
		}
		if (StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and ah.area_id like :areaId ");
			
			String strSql = sql.toString().replace("ana_compinfo_year", "ana_compinfo_area_year");
			sql.delete(0, sql.length());
			sql.append(strSql);
		}
		sql.append(" order by ah.date desc ");
		page.setRows(dao.getSqlMapList(sql.toString(), map)); 
		return page;
	}
	
	
	/**
	 * @category 按企业统计无分页(季度)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getSeaAnaByCompNoPage(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.del_comp_code,ah.del_comp_name,ah.date, ")
		.append(" ah.total_amount,ah.ret_amount,ah.western_amount,ah.eastern_amount,ah.eastern_ratio,ah.pro_count, ")
		.append(" ah.del_count,ah.del_amount,ah.recp_count,ah.recp_amount, ")
		.append(" ah.ret_ratio,ah.recp_ratio,del_ratio ")
		.append("  from ana_compinfo_sea ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("delCompName"))) {
			sql.append(" and (ah.del_comp_name like :delCompName or ah.del_comp_name_spel like :delCompName )");
			map.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startSea"))) {
			map.put("startSea", map.get("startSea").replaceAll("年", "0").replaceAll("季度", ""));
			sql.append(" and ah.date >= :startSea ");
		}
		if (StringUtils.isNotBlank(map.get("endSea"))) {
			map.put("endSea", map.get("endSea").replaceAll("年", "0").replaceAll("季度", ""));
			sql.append(" and ah.date <= :endSea ");
		}
		if (StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and ah.area_id like :areaId ");
			
			String strSql = sql.toString().replace("ana_compinfo_sea", "ana_compinfo_area_sea");
			sql.delete(0, sql.length());
			sql.append(strSql);
		}
		sql.append(" order by ah.date desc ");
		page.setRows(dao.getSqlMapList(sql.toString(), map)); 
		return page;
	}
	
	/**
	 * @category 按企业统计无分页(月)
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	@Override
	public Pagination getMonthAnaByCompNoPage(Pagination page) {
		String areaId = page.getConditions().get("areaId");
		if(StringUtils.isNotBlank(areaId)){
			return getWsjMonthAnaByCompNoPage(page);
		}
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.del_comp_code,ah.del_comp_name, ");
		
		if (StringUtils.isNotBlank(map.get("startMonth"))){
			sql.append(" sum(ah.total_amount/10000) total_amount,sum(ah.ret_amount/10000) ret_amount,sum(ah.western_amount/10000) western_amount,sum(ah.eastern_amount/10000) eastern_amount,sum(ah.eastern_amount)/sum(ah.total_amount) eastern_ratio,sum(ah.pro_count) pro_count, ")
			.append(" sum(ah.del_count) del_count,sum(ah.del_amount/10000) del_amount,sum(ah.recp_count) recp_count,sum(ah.recp_amount/10000) recp_amount, ")
			.append(" sum(ah.ret_amount)/sum(ah.total_amount) ret_ratio,sum(recp_amount)/sum(ah.total_amount) recp_ratio,sum(ah.del_amount)/sum(ah.total_amount) del_ratio ");
			
		}else {
			sql.append(" ah.date,ah.total_amount/10000 total_amount,ah.ret_amount/10000 ret_amount,ah.western_amount/10000 western_amount,ah.eastern_amount/10000 eastern_amount,ah.eastern_ratio,ah.pro_count, ")
			.append(" ah.del_count,ah.del_amount/10000 del_amount,ah.recp_count,ah.recp_amount/10000 recp_amount, ")
			.append(" ah.ret_ratio,ah.recp_ratio,del_ratio ");
			
		}
		
		sql.append("  from ana_compinfo_mon ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("delCompName"))) {
			sql.append(" and (ah.del_comp_name like :delCompName or ah.del_comp_name_spel like :delCompName )");
			map.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		
		if (StringUtils.isNotBlank(map.get("endMonth"))) {
			map.put("endMonth", map.get("endMonth").replaceAll("-", ""));
			sql.append(" and ah.date <= :endMonth ");
		}
		
		if (StringUtils.isNotBlank(map.get("startMonth"))) {
			map.put("startMonth", map.get("startMonth").replaceAll("-", ""));
			sql.append(" and ah.date >= :startMonth ");
			sql.append(" group by ah.del_comp_code ");
		}
		sql.append(" order by ah.date desc ");
		page.setRows(dao.getSqlMapList(sql.toString(), map)); 
		return page;
	}
	@SuppressWarnings("unchecked")
	@Override
	public List<Map<String, Object>> getMonthAnaByHospNoPage(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select * from ana_hospital_mon ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("hospName"))) {
			sql.append(" and (ah.hosp_name like :hospName or ah.hosp_spel_code like :hospName )");
			map.put("hospName", "%"+map.get("hospName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("startMonth"))) {
			map.put("startMonth", map.get("startMonth").replaceAll("-", ""));
			sql.append(" and ah.date >= :startMonth ");
		}
		if (StringUtils.isNotBlank(map.get("endMonth"))) {
			map.put("endMonth", map.get("endMonth").replaceAll("-", ""));
			sql.append(" and ah.date <= :endMonth ");
		}
		if (StringUtils.isNotBlank(map.get("areaId"))) {
			map.put("areaId", map.get("areaId"));
			sql.append(" and ah.hosp_area_id like :areaId ");
		}
		sql.append(" order by ah.date desc ");
		return (List<Map<String, Object>>) dao.getSqlMapList(sql.toString(), map);
	
	}

	
	@SuppressWarnings("unchecked")
	@Override
	public List<Map<String, Object>> getSeaAnaByHospNoPage(Pagination page) {

		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select * from ana_hospital_sea ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("hospName"))) {
			sql.append(" and (ah.hosp_name like :hospName or ah.hosp_spel_code like :hospName )");
			map.put("hospName", "%"+map.get("hospName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("starttime"))) {
			map.put("starttime", map.get("starttime").replaceAll("年", "0").replaceAll("季度", ""));
			sql.append(" and ah.date >= :starttime ");
		}
		if (StringUtils.isNotBlank(map.get("endtime"))) {
			map.put("endtime", map.get("endtime").replaceAll("年", "0").replaceAll("季度", ""));
			sql.append(" and ah.date <= :endtime ");
		}
		if (StringUtils.isNotBlank(map.get("areaId"))) {
			map.put("areaId", map.get("areaId"));
			sql.append(" and ah.hosp_area_id like :areaId ");
		}
		sql.append(" order by ah.date desc ");
		return (List<Map<String, Object>>) dao.getSqlMapList(sql.toString(), map);
	
	}

	
	@SuppressWarnings("unchecked")
	@Override
	public List<Map<String, Object>> getYearAnaByHospNoPage(Pagination page) {

		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select * from ana_hospital_year ah where 1=1  ");
		if (StringUtils.isNotBlank(map.get("hospName"))) {
			sql.append(" and (ah.hosp_name like :hospName or ah.hosp_spel_code like :hospName )");
			map.put("hospName", "%"+map.get("hospName")+"%");
		}
		if (StringUtils.isNotBlank(map.get("starttime"))) {
			sql.append(" and ah.date >= :starttime ");
		}
		if (StringUtils.isNotBlank(map.get("endtime"))) {
			sql.append(" and ah.date <= :endtime ");
		}
		if (StringUtils.isNotBlank(map.get("areaId"))) {
			map.put("areaId", map.get("areaId"));
			sql.append(" and ah.hosp_area_id like :areaId ");
		}
		sql.append(" order by ah.date desc ");
		return (List<Map<String, Object>>) dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 地区采购情况统计无分页(月)
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@Override
	public Pagination getAnaByAreaWithMonNoPage(Pagination page){
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select t.area_name,t.date,t.area_id, ");
		
		if (StringUtils.isNotBlank(map.get("startMon"))){
			sql.append(" sum(t.total_amount/10000) total_amount,sum(t.ret_amount/10000) ret_amount,sum(t.western_amount/10000) western_amount,sum(t.eastern_amount/10000) eastern_amount,sum(t.eastern_amount)/sum(t.total_amount) eastern_ratio,sum(t.pro_count) pro_count,sum(t.del_count) del_count,sum(t.del_amount/10000) del_amount,sum(t.recp_count) recp_count,sum(t.recp_amount/10000) recp_amount,sum(t.ret_amount)/sum(t.total_amount) ret_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
		}else {
			sql.append(" t.total_amount/10000 total_amount,t.ret_amount/10000 ret_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount,t.eastern_ratio,t.pro_count,t.del_count,t.del_amount/10000 del_amount,t.recp_count,t.recp_amount/10000 recp_amount,t.ret_ratio,t.recp_ratio,t.del_ratio ");
		}
		
		sql.append(" from ana_area_mon t")
		.append(" where 1=1");
		
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaId"))) {
			params.put("areaId", map.get("areaId"));
			sql.append(" and t.area_id like :areaId ");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		
		if (StringUtils.isNotBlank(map.get("endMon"))){
			sql.append(" and t.date <= :endMon");
			params.put("endMon", map.get("endMon"));
		}
		
		if (StringUtils.isNotBlank(map.get("startMon"))){
			sql.append(" and t.date >= :startMon");
			params.put("startMon", map.get("startMon"));
			sql.append(" group by t.area_id");
		}
		sql.append(" order by t.date desc ");
		page.setRows(dao.getSqlMapList(sql.toString(), params)); 
		return page;
	}
	
	/**
	 * @category 地区采购情况统计无分页(季度)
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@Override
	public Pagination getAnaByAreaWithSeaNoPage(Pagination page){
		StringBuffer sql = new StringBuffer()
		.append(" select t.area_name,t.date, ")
		.append(" t.total_amount,t.ret_amount,t.western_amount,t.eastern_amount,t.eastern_ratio,t.pro_count, ")
		.append(" t.del_count,t.del_amount,t.recp_count,t.recp_amount, ")
		.append(" t.ret_ratio,t.recp_ratio,t.del_ratio ")
		.append(" from ana_area_sea t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaId"))) {
			params.put("areaId", map.get("areaId"));
			sql.append(" and t.area_id like :areaId ");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startSea"))){
			sql.append(" and t.date >= :startSea");
			params.put("startSea", map.get("startSea"));
		}
		if (StringUtils.isNotBlank(map.get("endSea"))){
			sql.append(" and t.date <= :endSea");
			params.put("endSea", map.get("endSea"));
		}
		sql.append(" order by t.date desc ");
		page.setRows(dao.getSqlMapList(sql.toString(), params)); 
		return page;
	}
	
	/**
	 * @category 地区采购情况统计无分页(年度)
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@Override
	public Pagination getAnaByAreaWithYearNoPage(Pagination page){
		StringBuffer sql = new StringBuffer()
		.append(" select t.area_name,t.date, ")
		.append(" t.total_amount,t.ret_amount,t.western_amount,t.eastern_amount,t.eastern_ratio,t.pro_count, ")
		.append(" t.del_count,t.del_amount,t.recp_count,t.recp_amount, ")
		.append(" t.ret_ratio,t.recp_ratio,t.del_ratio ")
		.append(" from ana_area_year t")
		.append(" where 1=1");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		String areaId = map.get("area3");
		if (!StringUtils.isNotBlank(areaId)){
			areaId = map.get("area2");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = map.get("area1");
			}
		}
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
		}
		if (StringUtils.isNotBlank(map.get("areaId"))) {
			params.put("areaId", map.get("areaId"));
			sql.append(" and t.area_id like :areaId ");
		}
		if (StringUtils.isNotBlank(map.get("areaName"))){
			sql.append(" and t.area_name like :areaName");
			params.put("areaName", "%" + map.get("areaName").trim() + "%");
		}
		if (StringUtils.isNotBlank(map.get("startYear"))){
			sql.append(" and t.date >= :startYear");
			params.put("startYear", map.get("startYear"));
		}
		if (StringUtils.isNotBlank(map.get("endYear"))){
			sql.append(" and t.date <= :endYear");
			params.put("endYear", map.get("endYear"));
		}
		sql.append(" order by t.date desc ");
		page.setRows(dao.getSqlMapList(sql.toString(), params)); 
		return page;
	}
	
	/**
	 * @category 获取前7月的卫生局药品采购总量月汇总信息
	 * @date 2015-12-3
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<Map<String, Object>> getAnaChartByWsjAllMonth(Pagination page) {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql = new StringBuffer()
		.append(" select t.date,sum(t.total_amount/10000) total_amount,sum(IFNULL(t.del_amount/10000,'')) del_amount,sum(IFNULL(t.recp_amount/10000,'')) recp_amount ")
		.append(" from ana_area_mon t where  t.area_id like :areaId ");
		if(StringUtils.isNotBlank(page.getConditions().get("startMon"))){
			sql.append(" AND t.date >= :startMon");
			map.put("startMon", page.getConditions().get("startMon"));
			
		}else {
			sql.append(" AND :startMon <= t.date");
			map.put("startMon", ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -7)));
		}
		if(StringUtils.isNotBlank(page.getConditions().get("endMon"))){
			sql.append(" AND t.date <= :endMon ");
			map.put("endMon", page.getConditions().get("endMon"));
		}
		
		sql.append(" group by t.date ORDER BY t.date ");
		map.put("areaId", page.getConditions().get("areaId"));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
		
		
	}
	
	/**
	 * @category 前七个季度卫生局总体情况
	 * @date 2015-12-22
	 * @author lil
	 * @return List<Map<String, String>>
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<Map<String, Object>> getAnaChartByWsjAllSea(String areaId) {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql = new StringBuffer()
		.append(" select t.date,t.total_amount/10000 total_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount, ")
		.append(" t.ret_ratio,t.recp_ratio,t.del_ratio ")
		.append(" from ana_area_sea t where :date <= t.date and t.area_id like :areaId ORDER BY t.date");
		map.put("areaId", areaId);
		map.put("date", ParseDate.getSea(ParseDate.addMonth(new Date(), -21)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
	
	/**
	 * @category 前七年卫生局总体采购情况
	 * @date 2015年12月22日
	 * @author lil
	 * @param page
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<Map<String, Object>> getAnaChartByWsjAllYear(String areaId) {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql = new StringBuffer()
		.append(" select t.date,t.total_amount/10000 total_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount, ")
		.append(" t.ret_ratio,t.recp_ratio,t.del_ratio ")
		.append(" from ana_area_year t where :date <= t.date and t.area_id like :areaId ORDER BY t.date");
		map.put("areaId", areaId);
		map.put("date", ParseDate.parseShortYearFormat(ParseDate.addYear(new Date(), -7)));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	}
		@Override
	public Pagination getAnaHospdruginfoTotal(Pagination page) {
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select aht.*,bgi.qualityspec_name drug_name,bgi.form_name,bgi.spec_name, ")
		.append(" bgi.factor,bgi.unit_name,bgi.prod_compname,bgi.prod_compcode from ")
		.append(" ana_hospdruginfo_total_"+map.get("time") )
		.append(" aht join ")
		.append(" ( select distinct drug_code,qualityspec_name,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on bgi.drug_code =aht.drug_code where 1=1  ");
		
		if(StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and aht.hosp_area_id like :areaId ");
			params.put("areaId", map.get("areaId"));
		}
		if(StringUtils.isNotBlank(map.get("drugCode"))){
			sql.append(" and aht.drug_code = :drugCode ");
			params.put("drugCode", map.get("drugCode"));
		}
		
		if(StringUtils.isNotBlank(map.get("starttime")) || StringUtils.isNotBlank(map.get("endtime"))){
			if(StringUtils.isNotBlank(map.get("starttime"))){
				sql.append(" AND aht.date >= :starttime ");
				params.put("starttime", map.get("starttime"));
			}
			if(StringUtils.isNotBlank(map.get("endtime"))){
				sql.append(" AND aht.date <= :endtime ");
				params.put("endtime", map.get("endtime"));
			}	
		}else if(StringUtils.isNotBlank(map.get("starttimeByHosp")) || StringUtils.isNotBlank(map.get("endtimeByHosp"))){
			if(StringUtils.isNotBlank(map.get("starttimeByHosp"))){
				sql.append(" AND aht.date >= :starttimeByHosp ");
				params.put("starttimeByHosp", map.get("starttimeByHosp"));
			}
			if(StringUtils.isNotBlank(map.get("endtimeByHosp"))){
				sql.append(" AND aht.date <= :endtimeByHosp ");
				params.put("endtimeByHosp", map.get("endtimeByHosp"));
			}	
		}else{
			if(StringUtils.isNotBlank(map.get("date"))){
				sql.append(" AND aht.date = :date ");
				params.put("date", map.get("date"));
			}	
		}
		if(StringUtils.isNotBlank(map.get("hospCode"))){
			sql.append(" AND aht.hosp_code = :hospCode ");
			params.put("hospCode", map.get("hospCode"));
		}
		if(StringUtils.isNotBlank(map.get("hospName"))){
			sql.append(" AND ( aht.hosp_name like :hospName or aht.hosp_spel_code like :hospName ) ");
			params.put("hospName", map.get("hospName"));
		}
		if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and aht.drug_cat in ("+map.get("drugCat")+") ");
		}
		sql.append(" ORDER BY aht.date desc ");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		page.setRows(dao.getSqlMapList(sql.toString(), params)); 
		return page;
		
	}
		/**
	 * @category 医疗机构查看药品配送情况-加载图标
	 * @date 2015年12月24日10:50:43
	 * @author yxc
	 * @return
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<Map<String, Object>> getChartAnaHospdruginfoTotal(Pagination page) {
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		sql.append("select t.total_amount,t.del_amount,t.ret_amount,bgi.qualityspec_name drug_name from ")
		.append(" ana_hospdruginfo_total_"+page.getConditions().get("time") )
		.append(" t join ( select distinct drug_code,qualityspec_name,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on bgi.drug_code =t.drug_code  where t.date = :date ");
		if(StringUtils.isNotBlank(page.getConditions().get("areaId"))){
			sql.append(" and t.area_id like :areaId ");
			sql = new StringBuffer(sql.toString().replace("ana_druginfo_mon", "ana_areadruginfo_total_mon"));
			map.put("areaId", page.getConditions().get("areaId"));
		}
		sql.append("  order by t.total_amount desc  limit 10");
		map.put("date", page.getConditions().get("date"));
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
	
	}
	
	/**
	 * @category 配送企业药品统计信息
	 * @date 2015年12月1日10:55:55
	 * @author wangbing
	 * @return
	 */
	@Override
	public Pagination getAnaDelByDrug(Pagination page, String type){
		String areaId = page.getConditions().get("areaId");
		if(StringUtils.isNotBlank(areaId)){
			return getWsjAnaDelByDrug(page,type);
		}
		String delCompCode = page.getConditions().get("delCompCode");
		String date = page.getConditions().get("date");
		String drugName = page.getConditions().get("drugName");
		String drugCat = page.getConditions().get("drugCat");
		//type,1月2季度3年
		StringBuffer sql = new StringBuffer();
		
		if(date.split("-").length>1){
			sql.append(" select  t.drug_code,t.drug_cat,sum(t.total_amount/10000) total_amount, ")
			.append(" sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount,sum(t.ret_amount/10000) ret_amount,")
			.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio,bgi.qualityspec_name drug_name, ")
			.append(" bgi.form_name,bgi.spec_name,bgi.factor,bgi.unit_name,bgi.prod_compname,bgi.prod_compcode ");
		}else{
			sql.append(" select  t.drug_code,t.drug_cat,t.total_amount/10000 total_amount, ")
			.append(" t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount,t.ret_amount/10000 ret_amount,t.del_ratio,t.recp_ratio,t.ret_ratio,bgi.qualityspec_name drug_name, ")
			.append(" bgi.form_name,bgi.spec_name,bgi.factor,bgi.unit_name,bgi.prod_compname,bgi.prod_compcode ");
		}
		if("1".equals(type)) {
			sql.append(" from ana_deldruginfo_total_mon t ");
		}else if("2".equals(type)) {
			sql.append(" from ana_deldruginfo_total_sea t ");
		}else if("3".equals(type)) {
			sql.append(" from ana_deldruginfo_total_year t ");
		}
		sql.append(" left join (select DISTINCT drug_code,qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item) bgi on t.drug_code=bgi.drug_code  ")
		   .append(" where t.del_comp_code = :delCompCode ");
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("delCompCode", delCompCode);
		
		if(StringUtils.isNotBlank(drugName)){
			sql.append(" and (bgi.qualityspec_name like :drugName or bgi.qualityspec_name_spel like :drugName) ");
			params.put("drugName", "%"+drugName.trim()+"%");
		}
		if(StringUtils.isNotBlank(drugCat)){
			sql.append(" and t.drug_cat in ("+drugCat+") ");
		}
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2 group by t.drug_code ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date ");
			params.put("date", date);
		}
		sql.append(" ORDER BY t.date desc ");
		if(StringUtils.isNotBlank(page.getConditions().get("noPage"))){
			page.setRows(dao.getSqlMapList(sql.toString(), params));
			return page;
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}

	/**
	 * @category 药品跳地区汇总（时间点）
	 * @date 2015年12月28日09:46:13
	 * @author 应晓川
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaAreadruginfoTotal(Pagination page) {
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select * from ana_areadruginfo_total_"+map.get("time")+" where date =:date AND drug_code = :drugCode ");

		String areaId = StringUtils.isNotBlank(map.get("areaIdBySearch"))?map.get("areaIdBySearch"):(StringUtils.isNotBlank(map.get("areaId"))?map.get("areaId"):"");
		if(StringUtils.isNotBlank(areaId)){
			sql.append(" and area_id like :areaId ");
			params.put("areaId", areaId);
		}	
		params.put("date", map.get("date"));
		params.put("drugCode", map.get("drugCode"));

		sql.append(" ORDER BY area_id desc ");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		page.setRows(dao.getSqlMapList(sql.toString(), params)); 
		return page;
	}
	
	/**
	 * @category 药品跳地区汇总（时间段）
	 * @date 2015年12月28日09:46:13
	 * @author 应晓川
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaAreadruginfoTotalPool(Pagination page) {
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select \"").append(map.get("date")).append("\" date,")
		.append(" a.ar_fullname, ")
		.append(" sum(a.total_amount) total_amount, ")
		.append(" sum(a.del_amount) del_amount, ")
		.append(" sum(a.del_amount)/sum(a.total_amount) del_ratio, ")
		.append(" sum(a.recp_amount) recp_amount, ")
		.append(" sum(a.recp_amount)/sum(a.total_amount) recp_ratio ")
		.append(" from ana_areadruginfo_total_").append(map.get("time"))
		.append(" a where a.drug_code =:drugCode and a.date>=:starttime and a.date<=:endtime ");
		
		 params.put("drugCode", map.get("drugCode"));
		 params.put("starttime", map.get("starttime"));
		 params.put("endtime", map.get("endtime"));
		 
	
		String areaId = StringUtils.isNotBlank(map.get("areaIdBySearch"))?map.get("areaIdBySearch"):(StringUtils.isNotBlank(map.get("areaId"))?map.get("areaId"):"");
		if(StringUtils.isNotBlank(areaId)){
			sql.append(" and a.area_id like :areaId ");
			params.put("areaId", areaId);
		}	
		sql.append(" group BY a.area_id order by a.date desc ");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		page.setRows(dao.getSqlMapList(sql.toString(),  params)); 
		return page;
	}
	
	/**
	 * @category 药品跳配送企业汇总（时间点）
	 * @date 2015年12月28日10:02:46
	 * @author 应晓川
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaDeldruginfoTotal(Pagination page) {
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select adt.* from ana_deldruginfo_total_"+map.get("time")+" adt  ")
		//.append(" join std_compinfo sc on sc.comp_code = adt.del_comp_code   sc.comp_type=2   ")
		.append(" where adt.date = :date AND adt.drug_code = :drugCode ");
		
//		if(StringUtils.isNotBlank(map.get("areaId"))){
//			sql.append(" and sc.area_id like :areaId ");
//			params.put("areaId",map.get("areaId"));
//		}	
		params.put("date", map.get("date"));
		params.put("drugCode", map.get("drugCode"));
		if(StringUtils.isNotBlank(map.get("delCompName"))){
			sql.append(" AND (adt.del_comp_name like :delCompName or adt.del_comp_name_spel like :delCompName )");
			params.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		sql.append(" ORDER BY adt.del_comp_code desc ");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		page.setRows(dao.getSqlMapList(sql.toString(), params)); 
		return page;
	
	}
	/**
	 * @category 药品跳配送企业汇总（时间段）
	 * @date 2015年12月28日10:02:46
	 * @author 应晓川
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaDeldruginfoTotalPool(Pagination page) {
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select \"").append(map.get("date")).append("\" date,")
		.append(" a.del_comp_name, ")
		.append(" sum(a.total_amount) total_amount, ")
		.append(" sum(a.del_amount) del_amount, ")
		.append(" sum(a.del_amount)/sum(a.total_amount) del_ratio, ")
		.append(" sum(a.recp_amount) recp_amount, ")
		.append(" sum(a.recp_amount)/sum(a.total_amount) recp_ratio ")
		.append(" from ana_deldruginfo_total_").append(map.get("time"))
		.append(" a where a.drug_code =:drugCode and a.date>=:starttime and a.date<=:endtime ");
		
		 params.put("drugCode", map.get("drugCode"));
		 params.put("starttime", map.get("starttime"));
		 params.put("endtime", map.get("endtime"));
		 
//		if(StringUtils.isNotBlank(map.get("areaId"))){
//			sql.append(" and a.area_id like :areaId ");
//			params.put("areaId", map.get("areaId"));
//		}	
		if(StringUtils.isNotBlank(map.get("delCompName"))){
			sql.append(" AND (a.del_comp_name like :delCompName or a.del_comp_name_spel like :delCompName )");
			params.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		sql.append(" group BY a.del_comp_code order by a.date desc ");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		page.setRows(dao.getSqlMapList(sql.toString(),  params)); 
		return page;
	}
	/**
	 * @category 药品跳生产企业汇总（时间点）
	 * @date 2015年12月28日10:02:46
	 * @author 应晓川
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaProddruginfoTotal(Pagination page) {
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select adt.* from ana_proddruginfo_total_"+map.get("time")+" adt  ")
	//	.append(" join std_compinfo sc on sc.comp_code = adt.prod_comp_code   sc.comp_type=1   ")
		.append(" where adt.date = :date AND adt.drug_code = :drugCode ");
		
//		if(StringUtils.isNotBlank(map.get("areaId"))){
//			sql.append(" and sc.area_id like :areaId ");
//			params.put("areaId",map.get("areaId"));
//		}	
		params.put("date", map.get("date"));
		params.put("drugCode", map.get("drugCode"));
		if(StringUtils.isNotBlank(map.get("prodCompName"))){
			sql.append(" AND (adt.prod_comp_name like :prodCompName or adt.prod_comp_name_spel like :prodCompName )");
			params.put("prodCompName","%"+map.get("prodCompName")+"%");
		}
		sql.append(" ORDER BY adt.prod_comp_code desc ");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		page.setRows(dao.getSqlMapList(sql.toString(), params)); 
		return page;
	
	}

	/**
	 * @category 药品跳生产企业汇总（时间段）
	 * @date 2015年12月28日10:02:46
	 * @author 应晓川
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaProddruginfoTotalPool(Pagination page) {

		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select \"").append(map.get("date")).append("\" date,")
		.append(" a.prod_comp_name, ")
		.append(" sum(a.total_amount) total_amount, ")
		.append(" sum(a.del_amount) del_amount, ")
		.append(" sum(a.del_amount)/sum(a.total_amount) del_ratio, ")
		.append(" sum(a.recp_amount) recp_amount, ")
		.append(" sum(a.recp_amount)/sum(a.total_amount) recp_ratio, ")
		.append(" sum(a.western_amount) western_amount, ")
		.append(" sum(a.eastern_amount) eastern_amount, ")
		.append(" sum(a.eastern_amount)/sum(a.total_amount) eastern_ratio ")
		.append(" from ana_proddruginfo_total_").append(map.get("time"))
		.append(" a where a.drug_code =:drugCode and a.date>=:starttime and a.date<=:endtime ");
		
		 params.put("drugCode", map.get("drugCode"));
		 params.put("starttime", map.get("starttime"));
		 params.put("endtime", map.get("endtime"));
		 
//		if(StringUtils.isNotBlank(map.get("areaId"))){
//			sql.append(" and a.area_id like :areaId ");
//			params.put("areaId", map.get("areaId"));
//		}	
		if(StringUtils.isNotBlank(map.get("prodCompName"))){
			sql.append(" AND (a.prod_comp_name like :prodCompName or a.prod_comp_name_spel like :prodCompName )");
			params.put("prodCompName","%"+map.get("prodCompName")+"%");
		}
		sql.append(" group BY a.prod_comp_code order by a.date desc ");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		page.setRows(dao.getSqlMapList(sql.toString(),  params)); 
		return page;
	
	}
	
	/**
	 * @category 地区采购情况跳转
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@Override
	public Pagination getAnaByAreaTz(Pagination page) {
		
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map =page.getConditions(); 
		String hospClassifys = page.getConditions().get("hospClassifys");
		String hospType = page.getConditions().get("hospType");
		StringBuffer sql =new StringBuffer();
		//type 1医疗机构2药品3配送企业4生产企业
		String type = map.get("type");
		String areaId = AreaUtil.getAreaPrefix(map.get("areaId")) + "%";
		if("1".equals(type)) {
			sql.append(" select t.hosp_code,t.hosp_name,t.hosp_level_id,t.hosp_classify,t.hosp_ar_fullname, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_hospital_mon t where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("hospName"))) {
				sql.append(" and (t.hosp_name like :hospName or t.hosp_spel_code like :hospName )");
				params.put("hospName", "%"+map.get("hospName")+"%");
			}
			if(hospClassifys != null && hospClassifys !=""){
				params.put("hospClassifys", page.getConditions().get("hospClassifys"));
				sql.append(" and t.hosp_classify = :hospClassifys ");
			}
			if(hospType != null && hospType !=""){
				params.put("hospType", page.getConditions().get("hospType"));
				sql.append(" and t.hosp_level_id = :hospType ");
			}
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			if (StringUtils.isNotBlank(map.get("areaId"))) {
				sql.append(" and t.hosp_area_id like :areaId ");
				params.put("areaId", areaId);
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.hosp_code ");
			}
			
		}else if("2".equals(type)) {
			sql.append(" select t.drug_code,t.drug_cat,t.ar_fullname area_name,bgi.qualityspec_name drug_name,bgi.qualityspec_name_spel,bgi.form_name,bgi.spec_name,bgi.factor,bgi.unit_name,bgi.prod_compname,bgi.prod_compcode, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_areadruginfo_total_mon t left join ( select DISTINCT drug_code, qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on t.drug_code =bgi.drug_code where 1=1  ");
			if(StringUtils.isNotBlank(map.get("drugCat"))){
				sql.append(" and t.drug_cat in ("+map.get("drugCat")+") ");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			if (StringUtils.isNotBlank(map.get("drugName"))) {
				sql.append(" and (bgi.qualityspec_name like :drug_name OR bgi.qualityspec_name_spel like :drug_name )");
				params.put("drug_name", "%" + map.get("drugName").trim() + "%");
			}
			
			if (StringUtils.isNotBlank(map.get("areaId"))) {
				sql.append(" and t.area_id like :areaId ");
				params.put("areaId", areaId);
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.drug_code ");
			}
		}else if("3".equals(type)) {
			sql.append(" select t.del_comp_code,t.del_comp_name,t.ar_fullname area_name, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_compinfo_area_mon t where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("delCompName"))) {
				sql.append(" and (t.del_comp_name like :delCompName or t.del_comp_name_spel like :delCompName )");
				params.put("delCompName", "%"+map.get("delCompName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			if (StringUtils.isNotBlank(map.get("areaId"))) {
				sql.append(" and t.area_id like :areaId ");
				params.put("areaId", areaId);
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.del_comp_code ");
			}
		}else if("4".equals(type)) {
			sql.append(" select t.prod_comp_code,t.prod_comp_name,t.prod_comp_name_spel,t.ar_fullname area_name, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_prodcompinfo_area_mon t where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("prodCompName"))) {
				sql.append(" and (t.prod_comp_name like :prodCompName or t.prod_comp_name_spel like :prodCompName )");
				params.put("prodCompName", "%"+map.get("prodCompName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			if (StringUtils.isNotBlank(map.get("areaId"))) {
				sql.append(" and t.area_id like :areaId ");
				params.put("areaId", areaId);
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.prod_comp_code ");
			}
		}
		
		sql.append(" order by t.date desc ");
		
		if(StringUtils.isNotBlank(map.get("NoPage"))) {
			page.setRows(dao.getSqlMapList(sql.toString(), params));
			return page;
		}else {
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
	}
	
	/**
	 * @category 生产企业采购情况
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@Override
	public Pagination getAnaByProdcomp(Pagination page, String type) {
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select t.prod_comp_code,t.prod_comp_name,t.date, ");
		
		if (StringUtils.isNotBlank(map.get("startDate")) || StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" sum(t.total_amount/10000) total_amount,sum(t.ret_amount/10000) ret_amount,sum(t.western_amount/10000) western_amount,sum(t.eastern_amount/10000) eastern_amount,sum(t.eastern_amount)/sum(t.total_amount) eastern_ratio,sum(t.pro_count) pro_count,sum(t.del_count) del_count,sum(t.del_amount/10000) del_amount,sum(t.recp_count) recp_count,sum(t.recp_amount/10000) recp_amount,sum(t.ret_amount)/sum(t.total_amount) ret_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
		}else {
			sql.append(" t.total_amount/10000 total_amount,t.ret_amount/10000 ret_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount,t.eastern_ratio,t.pro_count,t.del_count,t.del_amount/10000 del_amount,t.recp_count,t.recp_amount/10000 recp_amount,t.ret_ratio,t.recp_ratio,t.del_ratio ");
		}
		if(StringUtils.isNotBlank(map.get("areaId"))) {
			sql.append("  from ana_prodcompinfo_area_mon t where 1=1  ");
		}else{
			sql.append("  from ana_prodcompinfo_mon t where 1=1  ");
		}
		//type 1月2季度3年
		/*if("1".equals(type)) {
			sql.append("  from ana_prodcompinfo_mon t where 1=1  ");
		}else if("2".equals(type)) {
			sql.append("  from ana_prodcompinfo_sea t where 1=1  ");
		}else if("3".equals(type)) {
			sql.append("  from ana_prodcompinfo_year t where 1=1  ");
		}*/
		
		if (StringUtils.isNotBlank(map.get("prodCompName"))) {
			sql.append(" and (t.prod_comp_name like :prodCompName or t.prod_comp_name_spel like :prodCompName )");
			params.put("prodCompName", "%"+map.get("prodCompName")+"%");
		}
		
		if (StringUtils.isNotBlank(map.get("endDate"))) {
			params.put("endDate", map.get("endDate"));
			sql.append(" and t.date <= :endDate ");
		}
		if (StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and t.area_id like :areaId ");
			params.put("areaId", map.get("areaId"));
		}
		
		if (StringUtils.isNotBlank(map.get("startDate"))) {
			params.put("startDate", map.get("startDate"));
			sql.append(" and t.date >= :startDate ");
			sql.append(" group by t.prod_comp_code ");
		}else if(!StringUtils.isNotBlank(map.get("startDate")) && StringUtils.isNotBlank(map.get("areaId"))) {
			sql.append(" group by t.date,t.prod_comp_code ");
		}
		
		sql.append(" order by t.date desc ");
		
		if (StringUtils.isNotBlank(map.get("NoPage"))) {
			page.setRows(dao.getSqlMapList(sql.toString(), params));
			return page;
		}else {
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		
	}
	
	/**
	 * @category 获取生产企业采购情况排名数据（月）
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> getAnaByProdcompChartWithMon(Pagination page) {
		
		Map<String, Object> map = new HashMap<String, Object>();
		StringBuffer sql =new StringBuffer();
		if(StringUtils.isNotBlank(page.getConditions().get("areaId"))) {
			sql.append("select t.prod_comp_name,sum(t.total_amount/10000) total_amount,t.date from  ana_prodcompinfo_area_mon t ");
		}else{
			sql.append("select t.prod_comp_name,t.total_amount/10000 total_amount,t.date from  ana_prodcompinfo_mon t ");
		}
	    sql.append(" where t.date = :date ");
		
		String startMon = "";
		if (StringUtils.isNotBlank(page.getConditions().get("startMon"))){
			startMon = page.getConditions().get("startMon");
		}else {
			startMon = ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1));
		}
		if(StringUtils.isNotBlank(page.getConditions().get("areaId"))) {
			sql.append(" and t.area_id like :areaId group by t.prod_comp_code order by sum(t.total_amount) ");
			map.put("areaId", page.getConditions().get("areaId"));
		}else {
			sql.append(" order by t.total_amount ");
		}
		sql.append(" desc limit 10");
		map.put("date", startMon);
		return (List<Map<String, Object>>)dao.getSqlMapList(sql.toString(), map);
		/*Map<String, String> map =page.getConditions(); 
		
		String startMonth = "";
		if (StringUtils.isNotBlank(map.get("startMonth"))) {
			startMonth = map.get("startMonth").replaceAll("-", "");
		}else {
			startMonth = ParseDate.parseDateToYm(ParseDate.addMonth(new Date(), -1));
		}
		
		
		StringBuffer sql = new StringBuffer()
		.append("select prod_comp_name,total_amount/10000 total_amount,date ")
		.append(" from ana_prodcompinfo_mon where date = :lastMonth ");
		if (StringUtils.isNotBlank(map.get("areaId"))){
			String areaId = map.get("areaId");
			sql.append(" and area_id like :areaId ");
			String strSql = sql.toString().replace("ana_prodcompinfo_mon", "ana_prodcompinfo_area_mon");
			sql.delete(0, sql.length());
			sql.append(strSql);
			map.clear();
			map.put("areaId", areaId);
			
		}else {
			map.clear();
		}
		sql.append(" order by total_amount desc  limit 10");
		
		map.put("lastMonth", startMonth);
		return (List<Map<String, Object>>) dao.getSqlMapList(sql.toString(), map);*/
	}
	
	
	
	
	
	/**
	 * @category 通体采购情况跳转采购药品(月度)
	 * @date 2015-12-3
	 * @param page
	 * @return
	 */
	@Override
	public Pagination getAnaByAllToDrugMon(Pagination page) {
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select adm.*,bgi.qualityspec_name drug_name,bgi.form_name,bgi.spec_name, ")
		.append(" bgi.factor,bgi.unit_name,bgi.prod_compname,bgi.prod_compcode ")
		.append(" from ana_druginfo_mon adm  join ")
		.append(" ( select distinct drug_code,qualityspec_name,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on bgi.drug_code =adm.drug_code where 1=1  ");
		
		if(StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and adm.area_id like :areaId ");
			sql = new StringBuffer(sql.toString().replace("ana_druginfo_mon", "ana_areadruginfo_total_mon"));
		}
		
		if(StringUtils.isNotBlank(map.get("starttime"))){
			sql.append(" AND date >= :starttime ");
		}
		if(StringUtils.isNotBlank(map.get("endtime"))){
			sql.append(" AND date <= :endtime ");
		}
		if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and adm.drug_cat in ("+map.get("drugCat")+") ");
			map.remove("drugCat");
		}
		sql.append(" ORDER BY adm.date desc ");
		return dao.getSqlPageMapList(sql.toString(), map, page);
	}

	
	/**
	 * @category 配送企业药品统计信息导出
	 * @date 2015年12月1日10:55:55
	 * @author wangbing
	 * @return
	 */

	@Override
	public Pagination getAnaDelByDrugExport(Pagination page, String type){
		String delCompCode = page.getConditions().get("delCompCode");
		String date = page.getConditions().get("date");
		String drugCat = page.getConditions().get("drugCat");
		//type,1月2季度3年
		StringBuffer sql = new StringBuffer();
		
		if(date.split("-").length>1){
			sql.append(" select t.drug_cat,sum(t.total_amount/10000) total_amount, ")
			.append(" sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount,sum(t.ret_amount/10000) ret_amount,")
			.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio,bgi.qualityspec_name drug_name ");
		}else{
			sql.append(" select distinct t.drug_cat,t.total_amount/10000 total_amount, ")
			.append(" t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount,t.ret_amount/10000 ret_amount,t.del_ratio,t.recp_ratio,t.ret_ratio,bgi.qualityspec_name drug_name ");
		}
		if("1".equals(type)) {
			sql.append(" from ana_deldruginfo_total_mon t ");
		}else if("2".equals(type)) {
			sql.append(" from ana_deldruginfo_total_sea t ");
		}else if("3".equals(type)) {
			sql.append(" from ana_deldruginfo_total_year t ");
		}
		sql.append(" left join ( select distinct drug_code,qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname from base_goods_item  ) bgi on t.drug_code=bgi.drug_code  ")
		   .append(" where t.del_comp_code = :delCompCode ");
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("delCompCode", delCompCode);
		
		if(StringUtils.isNotBlank(drugCat)){
			sql.append(" and t.drug_cat = : drugCat ");
			params.put("drugCat", drugCat);
		}
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2 group by t.drug_code ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date ");
			params.put("date", date);
		}
		sql.append(" ORDER BY t.date desc ");
		page.setRows(dao.getSqlMapList(sql.toString(), params));
		return page;
		
	}
	@Override
	public Pagination getAnaHospdruginfoTotalByDrugPool(Pagination page) {
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select \"").append(map.get("date")).append("\" date,")
		.append(" a.hosp_name, ")
		.append(" a.hosp_ar_fullname, ")
		.append(" bgi.qualityspec_name drug_name, ")
		.append(" a.hosp_classify, ")
		.append(" sum(a.total_amount) total_amount, ")
		.append(" sum(a.del_amount) del_amount, ")
		.append(" sum(a.del_amount)/sum(a.total_amount) del_ratio, ")
		.append(" sum(a.recp_amount) recp_amount, ")
		.append(" sum(a.recp_amount)/sum(a.total_amount) recp_ratio ")
		.append(" from ana_hospdruginfo_total_").append(map.get("time"))
		.append(" a join  ( select distinct drug_code,qualityspec_name from base_goods_item ) bgi  ")
		.append(" on bgi.drug_code =a.drug_code where a.date>=:starttime and a.date<=:endtime  "); 
	
		 params.put("starttime", map.get("starttime"));
		 params.put("endtime", map.get("endtime"));
		
		 if(StringUtils.isNotBlank(map.get("hospCode"))){
			sql.append(" and a.hosp_code =:hospCode ");
			params.put("hospCode", map.get("hospCode"));
		 }
		 if(StringUtils.isNotBlank(map.get("drugCode"))){
			sql.append(" and a.drug_code =:drugCode ");
			params.put("drugCode", map.get("drugCode"));
		 }
		 if(StringUtils.isNotBlank(map.get("hospName"))){
			sql.append(" and (a.hosp_name like :hospName or a.hosp_spel_code like :hospName )");
			params.put("hospName", "%"+map.get("hospName")+"%");
		 }
		 if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and a.drug_cat in ("+map.get("drugCat")+") ");
		 }
		 if(StringUtils.isNotBlank(map.get("hospClassify"))){
			sql.append(" and a.hosp_classify =:hospClassify ");
			params.put("hospClassify", map.get("hospClassify"));
		 }
		 if(StringUtils.isNotBlank(map.get("hospLevelId"))){
			sql.append(" and a.hosp_level_id =:hospLevelId ");
			params.put("hospLevelId", map.get("hospLevelId"));
		 }
		 if(StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and a.hosp_area_id like :areaId ");
			params.put("areaId", map.get("areaId")+"%");
		 }
		 
		sql.append(" group BY a.drug_code order by a.date desc ");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		page.setRows(dao.getSqlMapList(sql.toString(),  params)); 
		return page;
	}
	
	@Override
	public Pagination getAnaHospdruginfoTotalByDrug(Pagination page) {
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select a.*,bgi.qualityspec_name drug_name,bgi.qualityspec_name_spel,bgi.form_name,bgi.spec_name,bgi.factor,bgi.unit_name,bgi.prod_compname  from ana_hospdruginfo_total_").append(map.get("time"))
		.append(" a join  ( select distinct drug_code,qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname from base_goods_item  ) bgi  ")
		.append(" on bgi.drug_code =a.drug_code  where a.date=:date "); 
		
		 params.put("date", map.get("date"));
		 
		 if(StringUtils.isNotBlank(map.get("hospCode"))){
			sql.append(" and a.hosp_code =:hospCode ");
			params.put("hospCode", map.get("hospCode"));
		 }
		 if(StringUtils.isNotBlank(map.get("drugCode"))){
			sql.append(" and a.drug_code =:drugCode ");
			params.put("drugCode", map.get("drugCode"));
		 }
		
		 if(StringUtils.isNotBlank(map.get("drug_name"))){
				sql.append(" and (bgi.qualityspec_name like :drug_name or bgi.qualityspec_name_spel like :drug_name )");
				params.put("drug_name", "%"+map.get("drug_name")+"%");
		}
		 if(StringUtils.isNotBlank(map.get("hospName"))){
			sql.append(" and (a.hosp_name like :hospName or a.hosp_spel_code like :hospName )");
			params.put("hospName", "%"+map.get("hospName")+"%");
		 }
		 if(StringUtils.isNotBlank(map.get("drugCat"))){
			sql.append(" and a.drug_cat in ("+map.get("drugCat")+") ");
		 }
		 if(StringUtils.isNotBlank(map.get("hospClassify"))){
			sql.append(" and a.hosp_classify =:hospClassify ");
			params.put("hospClassify", map.get("hospClassify"));
		 }
		 if(StringUtils.isNotBlank(map.get("hospLevelId"))){
			sql.append(" and a.hosp_level_id =:hospLevelId ");
			params.put("hospLevelId", map.get("hospLevelId"));
		 }
		 if(StringUtils.isNotBlank(map.get("areaId"))){
			sql.append(" and a.hosp_area_id like :areaId ");
			params.put("areaId", map.get("areaId")+"%");
		 }
		sql.append(" order by a.hosp_code desc ");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		page.setRows(dao.getSqlMapList(sql.toString(),  params)); 
		return page;
	}

	
	
	/**
	 * @category 地区采购情况跳转无分页
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@Override
	public Pagination getAnaByAreaTzNoPage(Pagination page) {
		
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		//type 1医疗机构2药品3配送企业4生产企业
		String type = map.get("type");
		String areaId = AreaUtil.getAreaPrefix(map.get("areaId")) + "%";
		if("1".equals(type)) {
			sql.append(" select t.hosp_code,t.hosp_name,t.hosp_level_id,t.hosp_classify, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_hospdruginfo_total_mon t where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("hospName"))) {
				sql.append(" and (t.hosp_name like :hospName or t.hosp_spel_code like :hospName )");
				params.put("hospName", "%"+map.get("hospName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			if (StringUtils.isNotBlank(map.get("areaId"))) {
				sql.append(" and t.hosp_area_id like :areaId ");
				params.put("areaId", areaId);
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.hosp_code ");
			}
			
		}else if("2".equals(type)) {
			sql.append(" select t.drug_code,bgi.qualityspec_name drug_name,bgi.spec_name spec_name, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_areadruginfo_total_mon t  left join ( select DISTINCT drug_code, qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on t.drug_code =bgi.drug_code where 1=1  ");
			if(StringUtils.isNotBlank(map.get("drugCat"))){
				sql.append(" and t.drug_cat in ("+map.get("drugCat")+") ");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			if (StringUtils.isNotBlank(map.get("areaId"))) {
				sql.append(" and t.area_id like :areaId ");
				params.put("areaId", areaId);
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.drug_code ");
			}
		}else if("3".equals(type)) {
			sql.append(" select t.del_comp_code,t.del_comp_name, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_compinfo_area_mon t where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("delCompName"))) {
				sql.append(" and (t.del_comp_name like :delCompName or t.del_comp_name_spel like :delCompName )");
				params.put("delCompName", "%"+map.get("delCompName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			if (StringUtils.isNotBlank(map.get("areaId"))) {
				sql.append(" and t.area_id like :areaId ");
				params.put("areaId", areaId);
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.del_comp_code ");
			}
		}else if("4".equals(type)) {
			sql.append(" select t.prod_comp_code,t.prod_comp_name,t.prod_comp_name_spel, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_prodcompinfo_area_mon t where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("prodCompName"))) {
				sql.append(" and (t.prod_comp_name like :prodCompName or t.prod_comp_name_spel like :prodCompName )");
				params.put("prodCompName", "%"+map.get("prodCompName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			if (StringUtils.isNotBlank(map.get("areaId"))) {
				sql.append(" and t.area_id like :areaId ");
				params.put("areaId", areaId);
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.prod_comp_code ");
			}
		}
		
		sql.append(" order by t.date desc ");
		page.setRows(dao.getSqlMapList(sql.toString(), params)); 
		return page;
	}
	
	
	/**
	 * @category 总体采购情况跳转
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@Override
	public Pagination getAnaByAllTz(Pagination page) {
		
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map =page.getConditions(); 
		String drugCat = page.getConditions().get("drugCat");
		String hospClassifys = page.getConditions().get("hospClassifys");
		String hospType = page.getConditions().get("hospType");
		StringBuffer sql =new StringBuffer();
		//type 1医疗机构2药品3配送企业4生产企业5地区
		String type = map.get("type");
		if("1".equals(type)) {
			sql.append(" select t.hosp_code,t.hosp_name,t.hosp_level_id,t.hosp_classify,t.hosp_area_id,t.hosp_ar_fullname, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_hospital_mon t where 1=1  ");
			
			String areaId = page.getConditions().get("area3");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = page.getConditions().get("area2");
				if (!StringUtils.isNotBlank(areaId)){
					areaId = page.getConditions().get("area1");
				}
			}
			if (StringUtils.isNotBlank(areaId)){
				sql.append(" and t.hosp_area_id like :areaId");
				params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
			}
			if (StringUtils.isNotBlank(map.get("hospName"))) {
				sql.append(" and (t.hosp_name like :hospName or t.hosp_spel_code like :hospName )");
				params.put("hospName", "%"+map.get("hospName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("hospClassifys"))) {
				sql.append(" and t.hosp_classify = :hospClassifys ");
 				params.put("hospClassifys", hospClassifys );
			}
			if (StringUtils.isNotBlank(map.get("hospType"))) {
				sql.append(" and t.hosp_level_id = :hospType ");
				params.put("hospType", hospType );
			}
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.hosp_code ");
			}
			
		}else if("2".equals(type)) {
			sql.append(" select t.drug_code,t.drug_cat,bgi.qualityspec_name drug_name,bgi.spec_name spec_name,bgi.form_name,bgi.factor,bgi.unit_name,bgi.prod_compname, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_druginfo_mon t left join ( select DISTINCT drug_code, qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on t.drug_code =bgi.drug_code where 1=1  ");
			if(StringUtils.isNotBlank(map.get("drugCat"))){
				sql.append(" and t.drug_cat in ("+map.get("drugCat")+") ");
			 }
			if (StringUtils.isNotBlank(map.get("drugName"))) {
				sql.append(" and (bgi.qualityspec_name like :drugName or bgi.qualityspec_name_spel like :drugName )");
				params.put("drugName", "%"+map.get("drugName")+"%");
			}
						
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.drug_code ");
			}
		}else if("3".equals(type)) {
			sql.append(" select t.del_comp_code,t.del_comp_name, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_compinfo_mon t where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("delCompName"))) {
				sql.append(" and (t.del_comp_name like :delCompName or t.del_comp_name_spel like :delCompName )");
				params.put("delCompName", "%"+map.get("delCompName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.del_comp_code ");
			}
		}else if("4".equals(type)) {
			sql.append(" select t.prod_comp_code,t.prod_comp_name,t.prod_comp_name_spel, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_prodcompinfo_mon t where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("prodCompName"))) {
				sql.append(" and (t.prod_comp_name like :prodCompName or t.prod_comp_name_spel like :prodCompName )");
				params.put("prodCompName", "%"+map.get("prodCompName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.prod_comp_code ");
			}
		}else if("5".equals(type)) {
			sql.append(" select t.area_id,t.ar_shortname area_name, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_area_mon t where 1=1  ");
			
			String areaId = page.getConditions().get("area3");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = page.getConditions().get("area2");
				if (!StringUtils.isNotBlank(areaId)){
					areaId = page.getConditions().get("area1");
				}
			}
			if (StringUtils.isNotBlank(areaId)){
				sql.append(" and t.area_id like :areaId");
				params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
			}
			if (StringUtils.isNotBlank(map.get("areaName"))) {
				sql.append(" and (t.ar_shortname like :areaName )");
				params.put("areaName", "%"+map.get("areaName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.area_id ");
			}
		}
		
		sql.append(" order by t.date desc ");
		if(StringUtils.isNotBlank(map.get("NoPage"))) {
			page.setRows(dao.getSqlMapList(sql.toString(), params));
			return page;
		}else {
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
	}
	
	
	/**
	 * @category 总体采购情况跳转无分页
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@Override
	public Pagination getAnaByAllTzNoPage(Pagination page) {
		
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		//type 1医疗机构2药品3配送企业4生产企业5地区
		String type = map.get("type");
		if("1".equals(type)) {
			sql.append(" select t.hosp_code,t.hosp_name,t.hosp_level_id,t.hosp_classify, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_hospital_mon t where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("hospName"))) {
				sql.append(" and (t.hosp_name like :hospName or t.hosp_spel_code like :hospName )");
				params.put("hospName", "%"+map.get("hospName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.hosp_code ");
			}
			
		}else if("2".equals(type)) {
			sql.append(" select t.drug_code,t.drug_cat,bgi.qualityspec_name drug_name,bgi.spec_name spec_name, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_druginfo_mon t left join ( select DISTINCT drug_code, qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on t.drug_code =bgi.drug_code where 1=1  ");
			if (StringUtils.isNotBlank(map.get("drugName"))) {
				sql.append(" and (bgi.qualityspec_name like :drugName or bgi.spec_name like :drugName )");
				params.put("drugName", "%"+map.get("drugName")+"%");
			}
						
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.drug_code ");
			}
		}else if("3".equals(type)) {
			sql.append(" select t.del_comp_code,t.del_comp_name, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_compinfo_mon t where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("delCompName"))) {
				sql.append(" and (t.del_comp_name like :delCompName or t.del_comp_name_spel like :delCompName )");
				params.put("delCompName", "%"+map.get("delCompName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.del_comp_code ");
			}
		}else if("4".equals(type)) {
			sql.append(" select t.prod_comp_code,t.prod_comp_name,t.prod_comp_name_spel, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_prodcompinfo_mon t where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("prodCompName"))) {
				sql.append(" and (t.prod_comp_name like :prodCompName or t.prod_comp_name_spel like :prodCompName )");
				params.put("prodCompName", "%"+map.get("prodCompName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.prod_comp_code ");
			}
		}else if("5".equals(type)) {
			sql.append(" select t.area_id,t.ar_shortname area_name, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_area_mon t where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("areaName"))) {
				sql.append(" and (t.ar_shortname like :areaName )");
				params.put("areaName", "%"+map.get("areaName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.area_id ");
			}
		}
		
		sql.append(" order by t.date desc ");
		page.setRows(dao.getSqlMapList(sql.toString(), params));
		return page;
	}
	
	@Override
	public Pagination getAnaCompinfoByAreaWithMonExport(Pagination page){
		String delCompCode = page.getConditions().get("delCompCode");
		String date = page.getConditions().get("date");
		String area1 = page.getConditions().get("area1");
		String area2 = page.getConditions().get("area2");
		String area3 = page.getConditions().get("area3");
		StringBuffer sql = new StringBuffer();
		if(date.split("-").length>1){
			sql.append(" select t.area_id,t.area_name, ")
			.append(" sum(t.total_amount/10000) total_amount,sum(t.ret_amount/10000) ret_amount,sum(t.western_amount/10000) western_amount,sum(t.eastern_amount/10000) eastern_amount,sum(t.eastern_amount)/sum(t.total_amount) eastern_ratio,sum(t.pro_count) pro_count, ")
			.append(" sum(t.del_count) del_count,sum(t.del_amount/10000) del_amount,sum(t.recp_count) recp_count,sum(t.recp_amount/10000) recp_amount, ")
			.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio ")
			.append(" from ana_compinfo_area_mon t")
			.append(" where t.del_comp_code = :delCompCode ");
			
		}else{
			sql.append(" select t.area_id,t.area_name, ")
			.append(" t.total_amount/10000 total_amount,t.ret_amount/10000 ret_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount,t.eastern_ratio,t.pro_count, ")
			.append(" t.del_count,t.del_amount/10000 del_amount,t.recp_count,t.recp_amount/10000 recp_amount, ")
			.append(" t.ret_ratio,t.recp_ratio,t.del_ratio ")
			.append(" from ana_compinfo_area_mon t")
			.append(" where t.del_comp_code = :delCompCode ");
		}
		
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("delCompCode", delCompCode);
		String areaId = AreaUtil.getAreaStartCode(area1,area2,area3);
		if (StringUtils.isNotBlank(areaId)){
			sql.append(" and t.area_id like :areaId");
			params.put("areaId", areaId+ "%");
		}
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2 group by t.area_id ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date ");
			params.put("date", date);
		}
		page.setRows(dao.getSqlMapList(sql.toString(), params));
		return page;
	}
	
	@Override
	public Pagination getAnaDelByHosp(Pagination page){
		String delCompCode = page.getConditions().get("delCompCode");
		String hospName = page.getConditions().get("hospName");
		String date = page.getConditions().get("date");
		String area1 = page.getConditions().get("area1");
		String area2 = page.getConditions().get("area2");
		String area3 = page.getConditions().get("area3");
		String hospClassify = page.getConditions().get("hospClassify");
		String hospLevelId = page.getConditions().get("hospLevelId");
		String orgAreaId = page.getConditions().get("orgAreaId");
		StringBuffer sql = new StringBuffer();
		if(date.split("-").length>1){
			sql.append(" select t.hosp_code,t.hosp_name,t.hosp_classify,t.hosp_level_id,t.hosp_ar_fullname, ")
			.append(" sum(t.total_amount/10000) total_amount,sum(t.ret_amount/10000) ret_amount,sum(t.western_amount/10000) western_amount,sum(t.eastern_amount/10000) eastern_amount,sum(t.eastern_amount)/sum(t.total_amount) eastern_ratio,sum(t.pro_count) pro_count, ")
			.append(" sum(t.del_count) del_count,sum(t.del_amount/10000) del_amount,sum(t.recp_count) recp_count,sum(t.recp_amount/10000) recp_amount, ")
			.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio ")
			.append(" from ana_hospital_comp_mon t")
			.append(" where t.del_comp_code = :delCompCode and t.hosp_area_id like :areaId ");
			
		}else{
			sql.append(" select t.hosp_code,t.hosp_name,t.hosp_classify,t.hosp_level_id,t.hosp_ar_fullname, ")
			.append(" t.total_amount/10000 total_amount,t.ret_amount/10000 ret_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount,t.eastern_ratio,t.pro_count, ")
			.append(" t.del_count,t.del_amount/10000 del_amount,t.recp_count,t.recp_amount/10000 recp_amount, ")
			.append(" t.ret_ratio,t.recp_ratio,t.del_ratio ")
			.append(" from ana_hospital_comp_mon t")
			.append(" where t.del_comp_code = :delCompCode and t.hosp_area_id like :areaId ");
		}
		
		Map<String, Object> params = new HashMap<String, Object>();
		if(StringUtils.isNotBlank(orgAreaId)){
			sql.append(" and t.hosp_area_id like :orgAreaId ");
			params.put("orgAreaId", AreaUtil.getAreaPrefix(orgAreaId)+"%");
		}
		params.put("delCompCode", delCompCode);
		params.put("areaId", AreaUtil.getAreaStartCode(area1, area2, area3)+"%");
		if (StringUtils.isNotBlank(hospName)){
			sql.append(" and (t.hosp_name like :hospName or t.hosp_spel_code like :hospName)");
			params.put("hospName", "%"+hospName+ "%");
		}
		if(StringUtils.isNotBlank(hospLevelId)){
			sql.append(" and t.hosp_level_id like :hospLevelId  ");
			params.put("hospLevelId", hospLevelId);
		}
		
		if(StringUtils.isNotBlank(hospClassify)){
			sql.append(" and t.hosp_classify = :hospClassify  ");
			params.put("hospClassify", hospClassify);
		}
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2 group by t.hosp_code ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date ");
			params.put("date", date);
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	@Override
	public Pagination getAnaDelByHospExport(Pagination page){
		String delCompCode = page.getConditions().get("delCompCode");
		String hospName = page.getConditions().get("hospName");
		String date = page.getConditions().get("date");
		String area1 = page.getConditions().get("area1");
		String area2 = page.getConditions().get("area2");
		String area3 = page.getConditions().get("area3");
		String hospClassify = page.getConditions().get("hospClassify");
		String hospLevelId = page.getConditions().get("hospLevelId");
		String orgAreaId  = page.getConditions().get("orgAreaId");
		StringBuffer sql = new StringBuffer();
		if(date.split("-").length>1){
			sql.append(" select t.hosp_code,t.hosp_name,t.hosp_classify,t.hosp_level_id,t.hosp_ar_fullname, ")
			.append(" sum(t.total_amount/10000) total_amount,sum(t.ret_amount/10000) ret_amount,sum(t.western_amount/10000) western_amount,sum(t.eastern_amount/10000) eastern_amount,sum(t.eastern_amount)/sum(t.total_amount) eastern_ratio,sum(t.pro_count) pro_count, ")
			.append(" sum(t.del_count) del_count,sum(t.del_amount/10000) del_amount,sum(t.recp_count) recp_count,sum(t.recp_amount/10000) recp_amount, ")
			.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio ")
			.append(" from ana_hospital_comp_mon t")
			.append(" where t.del_comp_code = :delCompCode and t.hosp_area_id like :areaId ");
			
		}else{
			sql.append(" select t.hosp_code,t.hosp_name,t.hosp_classify,t.hosp_level_id,t.hosp_ar_fullname, ")
			.append(" t.total_amount/10000 total_amount,t.ret_amount/10000 ret_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount,t.eastern_ratio,t.pro_count, ")
			.append(" t.del_count,t.del_amount/10000 del_amount,t.recp_count,t.recp_amount/10000 recp_amount, ")
			.append(" t.ret_ratio,t.recp_ratio,t.del_ratio ")
			.append(" from ana_hospital_comp_mon t")
			.append(" where t.del_comp_code = :delCompCode and t.hosp_area_id like :areaId ");
		}
		
		Map<String, Object> params = new HashMap<String, Object>();
		if(StringUtils.isNotBlank(orgAreaId)){
			sql.append(" and t.hosp_area_id like :orgAreaId ");
			params.put("orgAreaId", AreaUtil.getAreaPrefix(orgAreaId)+"%");
		}
		params.put("delCompCode", delCompCode);
		params.put("areaId", AreaUtil.getAreaStartCode(area1, area2, area3)+"%");
		if (StringUtils.isNotBlank(hospName)){
			sql.append(" and (t.hosp_name like :hospName or t.hosp_spel_code like :hospName)");
			params.put("hospName", "%"+hospName+ "%");
		}
		if(StringUtils.isNotBlank(hospLevelId)){
			sql.append(" and t.hosp_level_id like :hospLevelId  ");
			params.put("hospLevelId", hospLevelId);
		}
		
		if(StringUtils.isNotBlank(hospClassify)){
			sql.append(" and t.hosp_classify = :hospClassify  ");
			params.put("hospClassify", hospClassify);
		}
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2 group by t.hosp_code ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date ");
			params.put("date", date);
		}
		page.setRows(dao.getSqlMapList(sql.toString(), params));
		return page;
	}
	
	@Override
	public Pagination getAnaDelByProdComp(Pagination page){
		String areaId = page.getConditions().get("areaId");
		if(StringUtils.isNotBlank(areaId)){
			return getWsjAnaDelByProdComp(page);
		}
		String delCompCode = page.getConditions().get("delCompCode");
		String prodCompName = page.getConditions().get("prodCompName");
		String date = page.getConditions().get("date");
		StringBuffer sql = new StringBuffer();
		if(date.split("-").length>1){
			sql.append(" select t.prod_comp_code,t.prod_comp_name, ")
			.append(" sum(t.total_amount/10000) total_amount,sum(t.ret_amount/10000) ret_amount,sum(t.western_amount/10000) western_amount,sum(t.eastern_amount/10000) eastern_amount,sum(t.eastern_amount)/sum(t.total_amount) eastern_ratio,sum(t.pro_count) pro_count, ")
			.append(" sum(t.del_count) del_count,sum(t.del_amount/10000) del_amount,sum(t.recp_count) recp_count,sum(t.recp_amount/10000) recp_amount, ")
			.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio ")
			.append(" from ana_compl_prodcomp_mon t")
			.append(" where t.del_comp_code = :delCompCode ");
			
		}else{
			sql.append(" select t.prod_comp_code,t.prod_comp_name, ")
			.append(" t.total_amount/10000 total_amount,t.ret_amount/10000 ret_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount,t.eastern_ratio,t.pro_count, ")
			.append(" t.del_count,t.del_amount/10000 del_amount,t.recp_count,t.recp_amount/10000 recp_amount, ")
			.append(" t.ret_ratio,t.recp_ratio,t.del_ratio ")
			.append(" from ana_compl_prodcomp_mon t")
			.append(" where t.del_comp_code = :delCompCode ");
		}
		
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("delCompCode", delCompCode);
		if (StringUtils.isNotBlank(prodCompName)){
			sql.append(" and (t.prod_comp_name like :prodCompName or t.prod_comp_name_spel like :prodCompName)");
			params.put("prodCompName", "%"+prodCompName+ "%");
		}
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2 group by t.prod_comp_code ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date ");
			params.put("date", date);
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	@Override
	public Pagination getAnaDelByProdCompExport(Pagination page){
		String areaId = page.getConditions().get("areaId");
		if(StringUtils.isNotBlank(areaId)){
			return getWsjAnaDelByProdCompExport(page);
		}
		
		String delCompCode = page.getConditions().get("delCompCode");
		String prodCompName = page.getConditions().get("prodCompName");
		String date = page.getConditions().get("date");
		StringBuffer sql = new StringBuffer();
		if(date.split("-").length>1){
			sql.append(" select t.prod_comp_code,t.prod_comp_name, ")
			.append(" sum(t.total_amount/10000) total_amount,sum(t.ret_amount/10000) ret_amount,sum(t.western_amount/10000) western_amount,sum(t.eastern_amount/10000) eastern_amount,sum(t.eastern_amount)/sum(t.total_amount) eastern_ratio,sum(t.pro_count) pro_count, ")
			.append(" sum(t.del_count) del_count,sum(t.del_amount/10000) del_amount,sum(t.recp_count) recp_count,sum(t.recp_amount/10000) recp_amount, ")
			.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio ")
			.append(" from ana_compl_prodcomp_mon t")
			.append(" where t.del_comp_code = :delCompCode ");
			
		}else{
			sql.append(" select t.prod_comp_code,t.prod_comp_name, ")
			.append(" t.total_amount/10000 total_amount,t.ret_amount/10000 ret_amount,t.western_amount/10000 western_amount,t.eastern_amount/10000 eastern_amount,t.eastern_ratio,t.pro_count, ")
			.append(" t.del_count,t.del_amount/10000 del_amount,t.recp_count,t.recp_amount/10000 recp_amount, ")
			.append(" t.ret_ratio,t.recp_ratio,t.del_ratio ")
			.append(" from ana_compl_prodcomp_mon t")
			.append(" where t.del_comp_code = :delCompCode ");
		}
		
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("delCompCode", delCompCode);
		if (StringUtils.isNotBlank(prodCompName)){
			sql.append(" and (t.prod_comp_name like :prodCompName or t.prod_comp_name_spel like :prodCompName)");
			params.put("hospName", "%"+prodCompName+ "%");
		}
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2 group by t.prod_comp_code ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date ");
			params.put("date", date);
		}
		page.setRows(dao.getSqlMapList(sql.toString(), params));
		return page;
	}
	
	
	
	
	/**
	 * @category 生产企业采购情况跳转
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@Override
	public Pagination getAnaByProdcompTz(Pagination page) {
		
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		//type 1医疗机构2药品3配送企业4地区
		String type = map.get("type");
		if("1".equals(type)) {
			sql.append(" select t.hosp_code,t.hosp_name,t.hosp_area_id,t.hosp_ar_fullname,t.hosp_level_id,t.hosp_classify,");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_hospital_prodcomp_mon t where 1=1  ");
			
			String areaId = page.getConditions().get("area3");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = page.getConditions().get("area2");
				if (!StringUtils.isNotBlank(areaId)){
					areaId = page.getConditions().get("area1");
				}
			}
			if (StringUtils.isNotBlank(areaId)){
				sql.append(" and t.hosp_area_id like :areaId");
				map.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
			}
			if (StringUtils.isNotBlank(map.get("hospName"))) {
				sql.append(" and (t.hosp_name like :hospName or t.hosp_spel_code like :hospName )");
				params.put("hospName", "%"+map.get("hospName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if (StringUtils.isNotBlank(map.get("prodCode"))){
				sql.append(" and t.prod_comp_code = :prodCode ");
				params.put("prodCode", map.get("prodCode"));
			}
			
			if(StringUtils.isNotBlank(map.get("hospClassifys"))){
				params.put("hospClassifys", map.get("hospClassifys"));
				sql.append(" and t.hosp_classify = :hospClassifys ");
			}
			if(StringUtils.isNotBlank(map.get("hospType"))){
				params.put("hospType", map.get("hospType"));
				sql.append(" and t.hosp_level_id = :hospType ");
			}
			
			if (StringUtils.isNotBlank(map.get("areaId"))){
				sql.append(" and t.hosp_area_id like :areaId ");
				params.put("areaId", map.get("areaId"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.hosp_code ");
			}
			
		}else if("2".equals(type)) {
			sql.append(" select t.drug_code,t.drug_cat,bgi.qualityspec_name drug_name,bgi.qualityspec_name_spel,bgi.form_name,bgi.spec_name,bgi.factor,bgi.unit_name,bgi.prod_compname,bgi.prod_compcode, ");
			if(page.getConditions().get("date").indexOf("-") >=0 || StringUtils.isNotBlank(map.get("areaId"))) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			if(StringUtils.isNotBlank(map.get("areaId"))) {
				sql.append("  from ana_prodcompdruginfo_area_mon t ");
			}else {
				sql.append("  from ana_proddruginfo_total_mon t ");
			}
			
			sql.append(" left join ( select DISTINCT drug_code, qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on t.drug_code =bgi.drug_code where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("drugName"))) {
				sql.append(" and (bgi.qualityspec_name like :drugName or bgi.qualityspec_name_spel like :drugName )");
				params.put("drugName", "%"+map.get("drugName")+"%");
			}
						
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if (StringUtils.isNotBlank(map.get("prodCode"))){
				sql.append(" and t.prod_comp_code = :prodCode ");
				params.put("prodCode", map.get("prodCode"));
			}
			
			if (StringUtils.isNotBlank(map.get("areaId"))){
				sql.append(" and t.area_id like :areaId ");
				params.put("areaId", map.get("areaId"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0 || StringUtils.isNotBlank(map.get("areaId"))) {
				sql.append(" group by t.drug_code ");
			}
		}else if("3".equals(type)) {
			sql.append(" select t.del_comp_code,t.del_comp_name, ");
			if(page.getConditions().get("date").indexOf("-") >=0 || StringUtils.isNotBlank(map.get("areaId"))) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			if (StringUtils.isNotBlank(map.get("areaId"))){
				sql.append("  from ana_compl_prodcomp_area_mon t where 1=1  ");
			}else {
				sql.append("  from ana_compl_prodcomp_mon t where 1=1  ");
			}
			
			if (StringUtils.isNotBlank(map.get("delCompName"))) {
				sql.append(" and (t.del_comp_name like :delCompName or t.del_comp_name_spel like :delCompName )");
				params.put("delCompName", "%"+map.get("delCompName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if (StringUtils.isNotBlank(map.get("prodCode"))){
				sql.append(" and t.prod_comp_code = :prodCode ");
				params.put("prodCode", map.get("prodCode"));
			}
			
			if (StringUtils.isNotBlank(map.get("areaId"))){
				sql.append(" and t.area_id like :areaId ");
				params.put("areaId", map.get("areaId"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0 || StringUtils.isNotBlank(map.get("areaId"))) {
				sql.append(" group by t.del_comp_code ");
			}
		}else if("4".equals(type)) {
			sql.append(" select t.area_id,t.ar_fullname area_name, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_prodcompinfo_area_mon t where 1=1  ");
			
			String areaId = page.getConditions().get("area3");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = page.getConditions().get("area2");
				if (!StringUtils.isNotBlank(areaId)){
					areaId = page.getConditions().get("area1");
				}
			}
			if (StringUtils.isNotBlank(areaId)){
				sql.append(" and t.area_id like :areaId");
				params.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if (StringUtils.isNotBlank(map.get("prodCode"))){
				sql.append(" and t.prod_comp_code = :prodCode ");
				params.put("prodCode", map.get("prodCode"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.area_id ");
			}
		}
		sql.append(" order by t.date desc ");
		if(StringUtils.isNotBlank(map.get("NoPage"))) {
			page.setRows(dao.getSqlMapList(sql.toString(), params));
			return page;
		}else {
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
	}

	/**
	 * @category 医院跳转至配送企业(时间点)
	 * @date 2015年12月28日14:34:47
	 * @author 应晓川
	 * @return
	 */
	@Override
	public Pagination getAnaHospitalCompMon(Pagination page) {

		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select a.* from  ana_hospital_comp_mon ")
		.append(" a where a.date=:date ");

		params.put("date", map.get("date"));
		if(StringUtils.isNotBlank(map.get("hospCode"))){
			sql.append(" and a.hosp_code =:hospCode ");
			params.put("hospCode", map.get("hospCode"));
		}	
		if(StringUtils.isNotBlank(map.get("delCompName"))){
			sql.append(" AND (a.del_comp_name like :delCompName or a.del_comp_name_spel like :delCompName )");
			params.put("delCompName","%"+ map.get("delCompName")+"%");
		}
		sql.append(" order by a.del_comp_code desc ");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		page.setRows(dao.getSqlMapList(sql.toString(),  params)); 
		return page;
	
	}

	/**
	 * @category 医院跳转至配送企业(时间段)
	 * @date 2015年12月28日14:34:47
	 * @author 应晓川
	 * @return
	 */
	@Override
	public Pagination getAnaHospitalCompMonPool(Pagination page) {
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select \"").append(map.get("date")).append("\" date,")
		.append(" a.del_comp_name, ")
		.append(" sum(a.total_amount) total_amount, ")
		.append(" sum(a.del_amount) del_amount, ")
		.append(" sum(a.del_amount)/sum(a.total_amount) del_ratio, ")
		.append(" sum(a.recp_amount) recp_amount, ")
		.append(" sum(a.recp_amount)/sum(a.total_amount) recp_ratio, ")
		.append(" sum(a.western_amount) western_amount, ")
		.append(" sum(a.eastern_amount) eastern_amount, ")
		.append(" sum(a.eastern_amount)/sum(a.total_amount) eastern_ratio ")
		.append(" from  ana_hospital_comp_mon ")
		.append(" a where a.date>=:starttime and a.date<=:endtime ");
		
		 params.put("starttime", map.get("starttime"));
		 params.put("endtime", map.get("endtime"));
		  
		if(StringUtils.isNotBlank(map.get("hospCode"))){
			sql.append(" and a.hosp_code =:hospCode ");
			params.put("hospCode", map.get("hospCode"));
		}	
		if(StringUtils.isNotBlank(map.get("delCompName"))){
			sql.append(" AND (a.del_comp_name like :delCompName or a.del_comp_name_spel like :delCompName )");
			params.put("delCompName","%"+ map.get("delCompName")+"%");
		}
		sql.append(" group BY a.del_comp_code order by a.date desc ");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		page.setRows(dao.getSqlMapList(sql.toString(),  params)); 
		return page;
	}

	/**
	 * @category 医院跳转至生产企业(时间点)
	 * @date 2015年12月28日14:34:47
	 * @author 应晓川
	 * @return
	 */
	@Override
	public Pagination getAnaHospitalProdcompMon(Pagination page) {
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select a.* from  ana_hospital_prodcomp_mon ")
		.append(" a where a.date=:date ");
		
		 params.put("date", map.get("date"));
		  
		if(StringUtils.isNotBlank(map.get("hospCode"))){
			sql.append(" and a.hosp_code =:hospCode ");
			params.put("hospCode", map.get("hospCode"));
		}	
		if(StringUtils.isNotBlank(map.get("prodCompName"))){
			sql.append(" AND (a.prod_comp_name like :prodCompName or a.prod_comp_name_spel like :prodCompName )");
			params.put("prodCompName", "%"+map.get("prodCompName")+"%");
		}
		sql.append("  order by a.prod_comp_code desc ");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		page.setRows(dao.getSqlMapList(sql.toString(),  params)); 
		return page;
	}

	/**
	 * @category 医院跳转至生产企业(时间段)
	 * @date 2015年12月28日14:34:47
	 * @author 应晓川
	 * @return
	 */
	@Override
	public Pagination getAnaHospitalProdcompMonPool(Pagination page) {
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map = page.getConditions();
		StringBuffer sql = new StringBuffer()
		.append(" select \"").append(map.get("date")).append("\" date,")
		.append(" a.prod_comp_name, ")
		.append(" sum(a.total_amount) total_amount, ")
		.append(" sum(a.del_amount) del_amount, ")
		.append(" sum(a.del_amount)/sum(a.total_amount) del_ratio, ")
		.append(" sum(a.recp_amount) recp_amount, ")
		.append(" sum(a.recp_amount)/sum(a.total_amount) recp_ratio, ")
		.append(" sum(a.western_amount) western_amount, ")
		.append(" sum(a.eastern_amount) eastern_amount, ")
		.append(" sum(a.eastern_amount)/sum(a.total_amount) eastern_ratio ")
		.append(" from  ana_hospital_prodcomp_mon ")
		.append(" a where a.date>=:starttime and a.date<=:endtime ");
		
		 params.put("starttime", map.get("starttime"));
		 params.put("endtime", map.get("endtime"));
		  
		if(StringUtils.isNotBlank(map.get("hospCode"))){
			sql.append(" and a.hosp_code =:hospCode ");
			params.put("hospCode", map.get("hospCode"));
		}	
		if(StringUtils.isNotBlank(map.get("prodCompName"))){
			sql.append(" AND (a.prod_comp_name like :prodCompName or a.prod_comp_name_spel like :prodCompName )");
			params.put("prodCompName", "%"+map.get("prodCompName")+"%");
		}
		sql.append(" group BY a.prod_comp_code order by a.date desc ");
		if(StringUtils.isNotBlank(map.get("Paging"))){
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
		page.setRows(dao.getSqlMapList(sql.toString(),  params)); 
		return page;
	}
	
	/**
	 * @category 获取   配送企业-药品-医疗机构   列表数据
	 * @date 2015年12月1日10:55:55
	 * @author wangbing
	 * @return
	 */
	@Override
	public Pagination getAnaDelByDrugHospWithMon(Pagination page, String type){
		String delCompCode = page.getConditions().get("delCompCode");
		String date = page.getConditions().get("date");
		String drugCode = page.getConditions().get("drugCode");
		String hospName = page.getConditions().get("hospName");
		String area1 = page.getConditions().get("area1");
		String area2 = page.getConditions().get("area2");
		String area3 = page.getConditions().get("area3");
		String hospClassify = page.getConditions().get("hospClassify");
		String hospLevelId = page.getConditions().get("hospLevelId");
		String orgAreaId = page.getConditions().get("orgAreaId");
		//type,1月2季度3年
		StringBuffer sql = new StringBuffer();
		
		if(date.split("-").length>1){
			sql.append(" select  t.hosp_classify,t.hosp_level_id,t.hosp_ar_fullname,t.hosp_code,t.hosp_name,t.drug_code,t.drug_cat,sum(t.total_amount/10000) total_amount, ")
			.append(" sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount,sum(t.ret_amount/10000) ret_amount,")
			.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio,bgi.qualityspec_name drug_name ");
		}else{
			sql.append(" select  t.hosp_classify,t.hosp_level_id,t.hosp_ar_fullname,t.hosp_code,t.hosp_name,t.drug_code,t.drug_cat,t.total_amount/10000 total_amount, ")
			.append(" t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount,t.ret_amount/10000 ret_amount,t.del_ratio,t.recp_ratio,t.ret_ratio,bgi.qualityspec_name drug_name ");
		}
		if("1".equals(type)) {
			sql.append(" from ana_hospital_compdrug_mon t ");
		}else if("2".equals(type)) {
			sql.append(" from ana_hospital_compdrug_sea t ");
		}else if("3".equals(type)) {
			sql.append(" from ana_hospital_compdrug_year t ");
		}
		sql.append(" left join (select DISTINCT drug_code,qualityspec_name,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item) bgi on t.drug_code=bgi.drug_code  ")
		   .append(" where t.del_comp_code = :delCompCode and t.drug_code = :drugCode and t.hosp_area_id like :areaId ");
		
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("delCompCode", delCompCode);
		params.put("drugCode", drugCode);
		params.put("areaId", AreaUtil.getAreaStartCode(area1, area2, area3)+"%");
		if(StringUtils.isNotBlank(orgAreaId)){
			sql.append(" and t.hosp_area_id like :orgAreaId ");
			params.put("orgAreaId", AreaUtil.getAreaPrefix(orgAreaId)+"%");
		}
		if(StringUtils.isNotBlank(hospName)){
			sql.append(" and (t.hosp_name like :hospName or t.hosp_spel_code like :hospName) ");
			params.put("hospName", "%"+hospName.trim()+"%");
		}
		
		if(StringUtils.isNotBlank(hospLevelId)){
			sql.append(" and t.hosp_level_id like :hospLevelId  ");
			params.put("hospLevelId", hospLevelId);
		}
		
		if(StringUtils.isNotBlank(hospClassify)){
			sql.append(" and t.hosp_classify = :hospClassify  ");
			params.put("hospClassify", hospClassify);
		}
		
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2 group by t.hosp_code ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date ");
			params.put("date", date);
		}
		sql.append(" ORDER BY t.date desc ");
		if(StringUtils.isNotBlank(page.getConditions().get("noPage"))){
			page.setRows(dao.getSqlMapList(sql.toString(), params));
			return page;
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}

	/**
	 * @category 生产企业采购情况跳转三级
	 * @date 2015年12月1日10:55:55
	 * @author lil
	 * @return
	 */
	@Override
	public Pagination getAnaByProdcompTzThree(Pagination page) {
		
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		//type 1医疗机构2药品3配送企业
		String type = map.get("type");
		if("1".equals(type)) {//医疗机构
			sql.append(" select DISTINCT t.drug_code,t.drug_cat,bgi.qualityspec_name drug_name,bgi.qualityspec_name_spel,bgi.form_name,bgi.spec_name,bgi.factor,bgi.unit_name,bgi.prod_compname,bgi.prod_compcode, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			
			sql.append("  from ana_hospital_prodcompdrug_mon t left join ( select DISTINCT drug_code, qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on t.drug_code =bgi.drug_code where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("drugName"))) {
				sql.append(" and (bgi.qualityspec_name like :drugName or bgi.qualityspec_name_spel like :drugName )");
				params.put("drugName", "%"+map.get("drugName")+"%");
			}
						
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if (StringUtils.isNotBlank(map.get("prodCode"))){
				sql.append(" and t.prod_comp_code = :prodCode ");
				params.put("prodCode", map.get("prodCode"));
			}
			if (StringUtils.isNotBlank(map.get("hospCode"))){
				sql.append(" and t.hosp_code = :hospCode ");
				params.put("hospCode", map.get("hospCode"));
			}
			
			if (StringUtils.isNotBlank(map.get("areaId"))){
				sql.append(" and t.hosp_area_id like :areaId ");
				params.put("areaId", map.get("areaId"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.drug_code ");
			}
		}else if("2".equals(type)) {//药品
			sql.append(" select t.hosp_code,t.hosp_name,t.hosp_area_id,t.hosp_ar_fullname,t.hosp_level_id,t.hosp_classify, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			sql.append("  from ana_hospital_prodcompdrug_mon t where 1=1  ");
			
			String areaId = page.getConditions().get("area3");
			if (!StringUtils.isNotBlank(areaId)){
				areaId = page.getConditions().get("area2");
				if (!StringUtils.isNotBlank(areaId)){
					areaId = page.getConditions().get("area1");
				}
			}
			if (StringUtils.isNotBlank(areaId)){
				sql.append(" and t.hosp_area_id like :areaId");
				map.put("areaId", AreaUtil.getAreaPrefix(areaId) + "%");
			}
			
			if (StringUtils.isNotBlank(map.get("hospName"))) {
				sql.append(" and (t.hosp_name like :hospName or t.hosp_spel_code like :hospName )");
				params.put("hospName", "%"+map.get("hospName")+"%");
			}
			
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if (StringUtils.isNotBlank(map.get("prodCode"))){
				sql.append(" and t.prod_comp_code = :prodCode ");
				params.put("prodCode", map.get("prodCode"));
			}
			if (StringUtils.isNotBlank(map.get("drugCode"))){
				sql.append(" and t.drug_code = :drugCode ");
				params.put("drugCode", map.get("drugCode"));
			}
			
			if (StringUtils.isNotBlank(map.get("areaId"))){
				sql.append(" and t.hosp_area_id like :areaId ");
				params.put("areaId", map.get("areaId"));
			}
			
			if(StringUtils.isNotBlank(map.get("hospClassifys"))){
				params.put("hospClassifys", map.get("hospClassifys"));
				sql.append(" and t.hosp_classify = :hospClassifys ");
			}
			if(StringUtils.isNotBlank(map.get("hospType"))){
				params.put("hospType", map.get("hospType"));
				sql.append(" and t.hosp_level_id = :hospType ");
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.hosp_code ");
			}
		}else if("3".equals(type)) {//配送企业
			sql.append(" select DISTINCT t.drug_code,t.drug_cat,bgi.qualityspec_name drug_name,bgi.qualityspec_name_spel,bgi.form_name,bgi.spec_name,bgi.factor,bgi.unit_name,bgi.prod_compname,bgi.prod_compcode, ");
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" sum(t.total_amount/10000) total_amount,sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount, ")
				.append(" sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.del_amount)/sum(t.total_amount) del_ratio ");
			}else {
				sql.append(" t.total_amount/10000 total_amount,t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount, ")
				.append(" t.recp_ratio,t.del_ratio ");
			}
			                   
			if (StringUtils.isNotBlank(map.get("areaId"))){
				sql.append("  from ana_compl_prodcomp_area_drug_mon t ");
			}else {
				sql.append("  from ana_compl_prodcomp_drug_mon t ");
			}
			sql.append(" left join ( select DISTINCT drug_code, qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item ) bgi on t.drug_code =bgi.drug_code where 1=1  ");
			
			if (StringUtils.isNotBlank(map.get("drugName"))) {
				sql.append(" and (bgi.qualityspec_name like :drugName or bgi.qualityspec_name_spel like :drugName )");
				params.put("drugName", "%"+map.get("drugName")+"%");
			}
						
			if (StringUtils.isNotBlank(map.get("startDate"))) {
				sql.append(" and t.date >= :startDate ");
				params.put("startDate", map.get("startDate"));
			}
			if (StringUtils.isNotBlank(map.get("endDate"))) {
				sql.append(" and t.date <= :endDate ");
				params.put("endDate", map.get("endDate"));
			}
			
			if (StringUtils.isNotBlank(map.get("prodCode"))){
				sql.append(" and t.prod_comp_code = :prodCode ");
				params.put("prodCode", map.get("prodCode"));
			}
			if (StringUtils.isNotBlank(map.get("delCode"))){
				sql.append(" and t.del_comp_code = :delCode ");
				params.put("delCode", map.get("delCode"));
			}
			
			if (StringUtils.isNotBlank(map.get("areaId"))){
				sql.append(" and t.area_id like :areaId ");
				params.put("areaId", map.get("areaId"));
			}
			
			if(page.getConditions().get("date").indexOf("-") >=0) {
				sql.append(" group by t.drug_code ");
			}
		}
		sql.append(" order by t.date desc ");
		if(StringUtils.isNotBlank(map.get("NoPage"))) {
			page.setRows(dao.getSqlMapList(sql.toString(), params));
			return page;
		}else {
			return dao.getSqlPageMapList(sql.toString(), params, page);
		}
	}
	
	/**
	 * @category 获取   配送企业-医疗机构-药品   列表数据
	 * @date 2015年12月1日10:55:55
	 * @author wangbing
	 * @return
	 */
	@Override
	public Pagination getAnaDelByHospDrugWithMon(Pagination page, String type){
		String delCompCode = page.getConditions().get("delCompCode");
		String date = page.getConditions().get("date");
		String hospCode = page.getConditions().get("hospCode");
		String drugName = page.getConditions().get("drugName");
		//type,1月2季度3年
		StringBuffer sql = new StringBuffer();
		
		if(date.split("-").length>1){
			sql.append(" select  t.hosp_code,t.hosp_name,t.drug_code,t.drug_cat,sum(t.total_amount/10000) total_amount, ")
			.append(" sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount,sum(t.ret_amount/10000) ret_amount,")
			.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio, ")
			.append(" bgi.qualityspec_name drug_name,bgi.qualityspec_name_spel,bgi.form_name,bgi.spec_name,bgi.factor,bgi.unit_name,bgi.prod_compname ");
		}else{
			sql.append(" select  t.hosp_code,t.hosp_name,t.drug_code,t.drug_cat,t.total_amount/10000 total_amount, ")
			.append(" t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount,t.ret_amount/10000 ret_amount,t.del_ratio,t.recp_ratio,t.ret_ratio, ")
			.append(" bgi.qualityspec_name drug_name,bgi.qualityspec_name_spel,bgi.form_name,bgi.spec_name,bgi.factor,bgi.unit_name,bgi.prod_compname ");
		}
		if("1".equals(type)) {
			sql.append(" from ana_hospital_compdrug_mon t ");
		}else if("2".equals(type)) {
			sql.append(" from ana_hospital_compdrug_sea t ");
		}else if("3".equals(type)) {
			sql.append(" from ana_hospital_compdrug_year t ");
		}
		sql.append(" left join (select DISTINCT drug_code,qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item) bgi on t.drug_code=bgi.drug_code  ")
		   .append(" where t.del_comp_code = :delCompCode and t.hosp_code = :hospCode ");
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("delCompCode", delCompCode);
		params.put("hospCode", hospCode);
		if(StringUtils.isNotBlank(drugName)){
			sql.append(" and ( bgi.qualityspec_name like :drugName or bgi.qualityspec_name_spel like :drugName ) ");
			params.put("drugName","%"+drugName.trim()+"%");
		}
	
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2 group by t.drug_code ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date ");
			params.put("date", date);
		}
		sql.append(" ORDER BY t.date desc ");
		if(StringUtils.isNotBlank(page.getConditions().get("noPage"))){
			page.setRows(dao.getSqlMapList(sql.toString(), params));
			return page;
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	/**
	 * @category 获取   配送企业-生产企业-药品   列表数据
	 * @date 2015年12月1日10:55:55
	 * @author wangbing
	 * @return
	 */
	@Override
	public Pagination getAnaDelByProdCompDrugWithMon(Pagination page, String type){
		String areaId = page.getConditions().get("areaId");
		if(StringUtils.isNotBlank(areaId)){
			return getWsjAnaDelByProdCompDrugWithMon(page,type);
		}
		String delCompCode = page.getConditions().get("delCompCode");
		String date = page.getConditions().get("date");
		String prodCompCode = page.getConditions().get("prodCompCode");
		String drugName = page.getConditions().get("drugName");
		//type,1月2季度3年
		StringBuffer sql = new StringBuffer();
		
		if(date.split("-").length>1){
			sql.append(" select  t.prod_comp_code,t.prod_comp_name,t.drug_code,t.drug_cat,sum(t.total_amount/10000) total_amount, ")
			.append(" sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount,sum(t.ret_amount/10000) ret_amount,")
			.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio, ")
			.append(" bgi.qualityspec_name drug_name,bgi.qualityspec_name_spel,bgi.form_name,bgi.spec_name,bgi.factor,bgi.unit_name ");
		}else{
			sql.append(" select  t.prod_comp_code,t.prod_comp_name,t.drug_code,t.drug_cat,t.total_amount/10000 total_amount, ")
			.append(" t.del_amount/10000 del_amount,t.recp_amount/10000 recp_amount,t.ret_amount/10000 ret_amount,t.del_ratio,t.recp_ratio,t.ret_ratio, ")
			.append(" bgi.qualityspec_name drug_name,bgi.qualityspec_name_spel,bgi.form_name,bgi.spec_name,bgi.factor,bgi.unit_name ");
		}
		if("1".equals(type)) {
			sql.append(" from ana_compl_prodcomp_drug_mon t ");
		}else if("2".equals(type)) {
			sql.append(" from ana_compl_prodcomp_drug_sea t ");
		}else if("3".equals(type)) {
			sql.append(" from ana_compl_prodcomp_drug_year t ");
		}
		sql.append(" left join (select DISTINCT drug_code,qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item) bgi on t.drug_code=bgi.drug_code  ")
		   .append(" where t.del_comp_code = :delCompCode and t.prod_comp_code = :prodCompCode ");
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("delCompCode", delCompCode);
		params.put("prodCompCode", prodCompCode);
		if(StringUtils.isNotBlank(drugName)){
			sql.append(" and (bgi.qualityspec_name like :drugName or bgi.qualityspec_name_spel like :drugName) ");
			params.put("drugName", "%"+drugName.trim()+"%");
		}
	
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2 group by t.drug_code ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date ");
			params.put("date", date);
		}
		sql.append(" ORDER BY t.date desc ");
		if(StringUtils.isNotBlank(page.getConditions().get("noPage"))){
			page.setRows(dao.getSqlMapList(sql.toString(), params));
			return page;
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	/**
	 * @category 配送企业药品统计信息-(卫生局)
	 * @date 2015年12月1日10:55:55
	 * @author wangbing
	 * @return
	 */
	private Pagination getWsjAnaDelByDrug(Pagination page, String type){
		String delCompCode = page.getConditions().get("delCompCode");
		String date = page.getConditions().get("date");
		String drugName = page.getConditions().get("drugName");
		String drugCat = page.getConditions().get("drugCat");
		String areaId = page.getConditions().get("areaId");
		//type,1月2季度3年
		StringBuffer sql = new StringBuffer();
		
		sql.append(" select  t.drug_code,t.drug_cat,sum(t.total_amount/10000) total_amount, ")
		.append(" sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount,sum(t.ret_amount/10000) ret_amount,")
		.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio,bgi.qualityspec_name drug_name, ")
		.append(" bgi.form_name,bgi.spec_name,bgi.factor,bgi.unit_name,bgi.prod_compname,bgi.prod_compcode ");
		if("1".equals(type)) {
			sql.append(" from ana_compdruginfo_area_mon t ");
		}else if("2".equals(type)) {
			sql.append(" from ana_compdruginfo_area_sea t ");
		}else if("3".equals(type)) {
			sql.append(" from ana_compdruginfo_area_year t ");
		}
		sql.append(" left join (select DISTINCT drug_code,qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item) bgi on t.drug_code=bgi.drug_code  ")
		   .append(" where t.del_comp_code = :delCompCode and t.area_id like :areaId ");
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("delCompCode", delCompCode);
		params.put("areaId", AreaUtil.getAreaPrefix(areaId)+"%");
		
		if(StringUtils.isNotBlank(drugName)){
			sql.append(" and (bgi.qualityspec_name like :drugName or bgi.qualityspec_name_spel like :drugName) ");
			params.put("drugName", "%"+drugName.trim()+"%");
		}
		if(StringUtils.isNotBlank(drugCat)){
			sql.append(" and t.drug_cat in ("+drugCat+") ");
		}
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2 ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date  ");
			params.put("date", date);
		}
		sql.append(" group by t.drug_code ORDER BY t.date desc ");
		if(StringUtils.isNotBlank(page.getConditions().get("noPage"))){
			page.setRows(dao.getSqlMapList(sql.toString(), params));
			return page;
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	
	/**
	 * @category 按企业统计无分页(月)卫生局
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	private Pagination getWsjMonthAnaByCompNoPage(Pagination page) {
		String areaId = page.getConditions().get("areaId");
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.del_comp_code,ah.del_comp_name,ah.date, ");
		
		sql.append(" sum(ah.total_amount/10000) total_amount,sum(ah.ret_amount/10000) ret_amount,sum(ah.western_amount/10000) western_amount,sum(ah.eastern_amount/10000) eastern_amount,sum(ah.eastern_amount)/sum(ah.total_amount) eastern_ratio,sum(ah.pro_count) pro_count, ")
		.append(" sum(ah.del_count) del_count,sum(ah.del_amount/10000) del_amount,sum(ah.recp_count) recp_count,sum(ah.recp_amount/10000) recp_amount, ")
		.append(" sum(ah.ret_amount)/sum(ah.total_amount) ret_ratio,sum(recp_amount)/sum(ah.total_amount) recp_ratio,sum(ah.del_amount)/sum(ah.total_amount) del_ratio ");
			
		sql.append("  from ana_compinfo_area_mon ah where ah.area_id like :areaId ");
		map.put("areaId", AreaUtil.getAreaPrefix(areaId)+"%");
		if (StringUtils.isNotBlank(map.get("delCompName"))) {
			sql.append(" and (ah.del_comp_name like :delCompName or ah.del_comp_name_spel like :delCompName )");
			map.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		
		if (StringUtils.isNotBlank(map.get("endMonth"))) {
			map.put("endMonth", map.get("endMonth").replaceAll("-", ""));
			sql.append(" and ah.date <= :endMonth ");
		}
		
		if (StringUtils.isNotBlank(map.get("startMonth"))) {
			map.put("startMonth", map.get("startMonth").replaceAll("-", ""));
			sql.append(" and ah.date >= :startMonth ");
		}
		sql.append(" group by ah.del_comp_code order by ah.date desc ");
		page.setRows(dao.getSqlMapList(sql.toString(), map)); 
		return page;
	}
	
	/**
	 * @category 按企业统计(月)卫生局
	 * @date 2015年12月1日10:55:55
	 * @return
	 */
	private Pagination getWsjMonthAnaByComp(Pagination page) {
		String areaId = page.getConditions().get("areaId");
		Map<String, Object> params = new HashMap<String, Object>();
		Map<String, String> map =page.getConditions(); 
		StringBuffer sql =new StringBuffer();
		sql.append(" select ah.del_comp_code,ah.del_comp_name,ah.date, ");
		sql.append(" sum(ah.total_amount/10000) total_amount,sum(ah.ret_amount/10000) ret_amount,sum(ah.western_amount/10000) western_amount,sum(ah.eastern_amount/10000) eastern_amount,sum(ah.eastern_amount)/sum(ah.total_amount) eastern_ratio,sum(ah.pro_count) pro_count, ")
			.append(" sum(ah.del_count) del_count,sum(ah.del_amount/10000) del_amount,sum(ah.recp_count) recp_count,sum(ah.recp_amount/10000) recp_amount, ")
			.append(" sum(ah.ret_amount)/sum(ah.total_amount) ret_ratio,sum(recp_amount)/sum(ah.total_amount) recp_ratio,sum(ah.del_amount)/sum(ah.total_amount) del_ratio ");
			
		sql.append("  from ana_compinfo_area_mon ah where ah.area_id like :areaId  ");
		params.put("areaId", AreaUtil.getAreaPrefix(areaId)+"%");
		
		
		if (StringUtils.isNotBlank(map.get("delCompName"))) {
			sql.append(" and (ah.del_comp_name like :delCompName or ah.del_comp_name_spel like :delCompName )");
			params.put("delCompName", "%"+map.get("delCompName")+"%");
		}
		
		if (StringUtils.isNotBlank(map.get("endMonth"))) {
			params.put("endMonth", map.get("endMonth").replaceAll("-", ""));
			sql.append(" and ah.date <= :endMonth ");
		}
		if (StringUtils.isNotBlank(map.get("startMonth"))) {
			params.put("startMonth", map.get("startMonth").replaceAll("-", ""));
			sql.append(" and ah.date >= :startMonth ");
			sql.append(" group by ah.del_comp_code ");
		}else {
			sql.append(" group by ah.date,ah.del_comp_code ");
		}
		sql.append(" order by ah.date desc ");
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	
	private Pagination getWsjAnaDelByProdComp(Pagination page){
		String delCompCode = page.getConditions().get("delCompCode");
		String prodCompName = page.getConditions().get("prodCompName");
		String date = page.getConditions().get("date");
		String areaId = page.getConditions().get("areaId");
		StringBuffer sql = new StringBuffer();
		sql.append(" select t.prod_comp_code,t.prod_comp_name, ")
			.append(" sum(t.total_amount/10000) total_amount,sum(t.ret_amount/10000) ret_amount,sum(t.western_amount/10000) western_amount,sum(t.eastern_amount/10000) eastern_amount,sum(t.eastern_amount)/sum(t.total_amount) eastern_ratio,sum(t.pro_count) pro_count, ")
			.append(" sum(t.del_count) del_count,sum(t.del_amount/10000) del_amount,sum(t.recp_count) recp_count,sum(t.recp_amount/10000) recp_amount, ")
			.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio ")
			.append(" from ana_compl_prodcomp_area_mon t")
			.append(" where t.del_comp_code = :delCompCode and t.area_id like :areaId ");
			
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("areaId", AreaUtil.getAreaPrefix(areaId)+"%");
		params.put("delCompCode", delCompCode);
		if (StringUtils.isNotBlank(prodCompName)){
			sql.append(" and (t.prod_comp_name like :prodCompName or t.prod_comp_name_spel like :prodCompName)");
			params.put("prodCompName", "%"+prodCompName+ "%");
		}
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2  ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date ");
			params.put("date", date);
		}
		sql.append(" group by t.prod_comp_code ");
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
	
	private Pagination getWsjAnaDelByProdCompExport(Pagination page){
		String delCompCode = page.getConditions().get("delCompCode");
		String prodCompName = page.getConditions().get("prodCompName");
		String date = page.getConditions().get("date");
		String areaId = page.getConditions().get("areaId");
		StringBuffer sql = new StringBuffer();
		sql.append(" select t.prod_comp_code,t.prod_comp_name, ")
			.append(" sum(t.total_amount/10000) total_amount,sum(t.ret_amount/10000) ret_amount,sum(t.western_amount/10000) western_amount,sum(t.eastern_amount/10000) eastern_amount,sum(t.eastern_amount)/sum(t.total_amount) eastern_ratio,sum(t.pro_count) pro_count, ")
			.append(" sum(t.del_count) del_count,sum(t.del_amount/10000) del_amount,sum(t.recp_count) recp_count,sum(t.recp_amount/10000) recp_amount, ")
			.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio ")
			.append(" from ana_compl_prodcomp_area_mon t")
			.append(" where t.del_comp_code = :delCompCode and t.area_id like :areaId ");
			
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("areaId", AreaUtil.getAreaPrefix(areaId)+"%");
		params.put("delCompCode", delCompCode);
		if (StringUtils.isNotBlank(prodCompName)){
			sql.append(" and (t.prod_comp_name like :prodCompName or t.prod_comp_name_spel like :prodCompName)");
			params.put("prodCompName", "%"+prodCompName+ "%");
		}
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2  ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date ");
			params.put("date", date);
		}
		sql.append(" group by t.prod_comp_code ");
		page.setRows(dao.getSqlMapList(sql.toString(), params));
		return page;
	}
	
	/**
	 * @category 获取   配送企业-生产企业-药品   列表数据
	 * @date 2015年12月1日10:55:55
	 * @author wangbing
	 * @return
	 */
	private Pagination getWsjAnaDelByProdCompDrugWithMon(Pagination page, String type){
		String areaId = page.getConditions().get("areaId");
		String delCompCode = page.getConditions().get("delCompCode");
		String date = page.getConditions().get("date");
		String prodCompCode = page.getConditions().get("prodCompCode");
		String drugName = page.getConditions().get("drugName");
		//type,1月2季度3年
		StringBuffer sql = new StringBuffer();
		sql.append(" select  t.prod_comp_code,t.prod_comp_name,t.drug_code,t.drug_cat,sum(t.total_amount/10000) total_amount, ")
			.append(" sum(t.del_amount/10000) del_amount,sum(t.recp_amount/10000) recp_amount,sum(t.ret_amount/10000) ret_amount,")
			.append(" sum(t.del_amount)/sum(t.total_amount) del_ratio,sum(t.recp_amount)/sum(t.total_amount) recp_ratio,sum(t.ret_amount)/sum(t.total_amount) ret_ratio, ")
			.append(" bgi.qualityspec_name drug_name,bgi.qualityspec_name_spel,bgi.form_name,bgi.spec_name,bgi.factor,bgi.unit_name ");
		if("1".equals(type)) {
			sql.append(" from ana_compl_prodcomp_area_drug_mon t ");
		}else if("2".equals(type)) {
			sql.append(" from ana_compl_prodcomp_area_drug_sea t ");
		}else if("3".equals(type)) {
			sql.append(" from ana_compl_prodcomp_area_drug_year t ");
		}
		sql.append(" left join (select DISTINCT drug_code,qualityspec_name,qualityspec_name_spel,form_name,spec_name,factor,unit_name,prod_compname,prod_compcode from base_goods_item) bgi on t.drug_code=bgi.drug_code  ")
		   .append(" where t.del_comp_code = :delCompCode and t.prod_comp_code = :prodCompCode and t.area_id like :areaId ");
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("delCompCode", delCompCode);
		params.put("prodCompCode", prodCompCode);
		params.put("areaId", AreaUtil.getAreaPrefix(areaId)+"%");
		if(StringUtils.isNotBlank(drugName)){
			sql.append(" and (bgi.qualityspec_name like :drugName or bgi.qualityspec_name_spel like :drugName) ");
			params.put("drugName", "%"+drugName.trim()+"%");
		}
	
		if(date.split("-").length>1){
			sql.append(" and t.date >= :date1 and t.date <= :date2  ");
			params.put("date1", date.split("-")[0]);
			params.put("date2", date.split("-")[1]);
		}else{
			sql.append(" and t.date = :date ");
			params.put("date", date);
		}
		sql.append(" group by t.drug_code ORDER BY t.date desc ");
		if(StringUtils.isNotBlank(page.getConditions().get("noPage"))){
			page.setRows(dao.getSqlMapList(sql.toString(), params));
			return page;
		}
		return dao.getSqlPageMapList(sql.toString(), params, page);
	}
}
